php - Regex doesn't get all before -


i have following string, want before a+.

am missing something?

string:

abcd www 6587 sm a+++ab 

regex:

([0-9a-za-z]*?) a\+ 

output:

 sm a+ 

desired output:

abcd www 6587 sm 

solution:

([0-9a-za-z].*?) a\+ 

was missing . (dot)

http://www.regexr.com/

use zero-width lookahead assertion

^.*(?=a\+) 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -