Reputation: 31
I am stuck in a problem. Actually developing search functionality. I am searching pattern for example in a following string:
test-123,this is demo.
testing?123,this is demo.
testing!jack,thanks.
Above are the three lines.
What I want is as soon as I enter test
it will search all the text (i.e all three lines) and come with result:
test-123
testing?123
testing!jack
It will search from beginning of every line till the comma character and would display the matched string. It should not truncate the special character before comma part.
Like for example
test
testing
testing
The Regular Expression which I am using and displaying the above pattern is
wordExp = ^wordHere\\w*
var iRegExp:RegExp = new RegExp(wordExp, "/gm");
It should include all the character before comma.
Please suggest the regular expression for above problem.
Upvotes: 1
Views: 80
Reputation: 2768
I think you should change \w to [^,]*
Something like this, if your line will always start with given word:
^wordHere[^,]*
OR can be everywhere before comma :
^[^,]*wordHere[^,]*
I hope I helped
Upvotes: 1