In JavaScript RegExp how to return what is match so far.
For example:
"123567890".match(/1234567890/i) returns "123"
"abcede".match(/abcdef/i) return "abc"
In another word return what is matched so far and disregarding the rest even if the whole regexp doesn't match.
>>54929162
it returns an array and it ony returns one item in the array since you have ony one match
>>54929289
Close but not quite. Look at the examples again.
The flag might be wrong, but you'll get the idea.
Even if the whole regexp doesn't match it should still return what is matched so far starting from the left once it stop matching.
So "abcedeabc".match(/abcde/i) will only return "abc" because that is what it was matched so far.
>>54930035
it returns null to me in chromium
>>54930177
That is not a concrete example. That is what I intending for it to do.
>>54930212
then use expressions which match multiple letters
abc.+ for example
You can't just stop matching half way, regular expressions either have a match or not.
>>54930212
Try searching for "partial match"
>>54930254
also, you could capture the difference (if you need it)
>>54929162"123567890".match(/1234567890|123456789|12345678|1234567|123456|12345|1234|123|12|1/i) returns "123"
"abcede".match(/abcdef|abcde|abcd|abc|ab|a/i) returns "abc"
>>54930342
you could even write a function to generate that
>>54930261
That might be what I was looking for, but it looks like regex might not be able to do it as my regex is more complex than the example that was given so as what I also trying to match.
>>54932329
My regex is very dynamic not static also the same for input or string that I'm trying to match.
>>54932363
I guess the only to do this is to make each sub regex of the whole regex optional and then go from there.