Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,161,464 members, 7,846,948 topics. Date: Saturday, 01 June 2024 at 08:07 AM

Javascript Gurus In The House, Help A Learner. - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Javascript Gurus In The House, Help A Learner. (616 Views)

Gurus In The House I Need Your Honest Reviews / Where Are The Paypal Gurus In The House, Check This Out... / Help.... Opencart Gurus In The House (2) (3) (4)

(1) (Reply) (Go Down)

Javascript Gurus In The House, Help A Learner. by David(m): 11:15am On Apr 20, 2013
Please. How would can i search for words before a word in javascript. E.g
if i want to search for words or number that comes before X.
I.e
2X +5
THE output should be 2. I tried the regexp but didnt know how to go about it. Am a learner. Please help. Thanks.
Re: Javascript Gurus In The House, Help A Learner. by yawatide(f): 12:06pm On Apr 20, 2013
search for "javascript substring". Something should come up that will be of help to you.

Good luck!
Re: Javascript Gurus In The House, Help A Learner. by Nobody: 12:09pm On Apr 20, 2013
giving you answers doesn't encourage programming instead it encourages this type of request, read more of regexp. thanks

1 Like

Re: Javascript Gurus In The House, Help A Learner. by David(m): 7:08am On Apr 21, 2013
Yeah. Thanks i got a clue. Will be using the .split() function.
Re: Javascript Gurus In The House, Help A Learner. by yawatide(f): 12:02pm On Apr 21, 2013
I am thinking, based on your problem, split may not be the answer. There is a function (i blv it is substr) where you pass in a string and a starting and ending point, and it gives you the exact character(s) at the ending point. Split will give you characters based on a delimiter and return it as arrays.

Think again and use the best option.

good luck!

1 Like

Re: Javascript Gurus In The House, Help A Learner. by Nobody: 12:15pm On Apr 21, 2013
substr is not right that only takes a segment of code that you know the pattern e.g 2x-5 but what of 5x-7+(2x + 5) regular expression fits the scenario perfectly.
Re: Javascript Gurus In The House, Help A Learner. by yawatide(f): 10:30pm On Apr 21, 2013
^^^ I guess it depends on the kinds of strings that OP wants to manipulate

(1) (Reply)

Tutorial & Software To Build Your Small Business Portfolio Website Yourself / How To Market Your Skills As A Webdeveloper / Seoclerks Vs Seomarts

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.