Matching Word with regular expression

Posted by lbar on Stack Overflow See other posts from Stack Overflow or by lbar
Published on 2012-09-07T09:31:31Z Indexed on 2012/09/07 9:37 UTC
Read the original article Hit count: 135

Filed under:
|

I have the following text file:

...
"somewords MYWORD";123123123123
"someother MYWORDOTHER";456456456456
"somedifferent MYWORDDIFFERENT";789789789
...

i need to match the word MYWORD, MYWORDOTHER, MYWORDDIFFERENT and then substitute the space before this word with ";". Someone can figure out a regex?

I have done something like that:

 +[^ ][^ ][^ ][^ ][^ ][^ ][^ ]";

but this works only with a specific word lenght. I need to modify to get any word of any leght.

Any help? Thank you.

© Stack Overflow or respective owner

Related posts about php

Related posts about regex