₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,176 members, 8,420,663 topics. Date: Friday, 05 June 2026 at 08:31 AM

Toggle theme

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

Nairaland ForumScience/TechnologyWebmastersJavascript Gurus In The House, Help A Learner. (683 Views)

1 Reply (Go Down)

Javascript Gurus In The House, Help A Learner. by David(op): 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
Re: Javascript Gurus In The House, Help A Learner. by David(op): 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!
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

Gurus In The House I Need Your Honest ReviewsWhere Are The Paypal Gurus In The House, Check This Out...Help.... Opencart Gurus In The House234

Welcome To Websites Of Federal Ministries (1)News UpdatePlease To All Nairalander, I Need Joomla Setup