₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,203 members, 8,449,121 topics. Date: Tuesday, 21 July 2026 at 10:48 AM

Toggle theme

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

Nairaland ForumScience/TechnologyWebmastersJavascript Gurus In The House, Help A Learner. (700 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

Get An Original Article Written FreeImprove Your Serp’s With Google Data Highlighter ToolNeed D Best Website Proposal