![]() ![]() You may want to consider if you want at least one space. * will match 0 or more spaces so it will match wordAwordB.Of course, if you do want to match lines with wordc after wordB then you shouldn’t use a negative lookahead. If you want to match against more than one space before wordc you can use (?!\s*wordc) for 0 or more spaces or (?!\s* wordc) for 1 or more spaces depending on what your intention is. You may want to be more precise and use (?!\swordc). Currently you are relying on the space after ?! to match the whitespace. (?! wordc) is a negative lookahead, so you wont match lines wordA wordB wordc which is assume is intended (and is why the last line is not matched).Note that all matches are replaced no matter how many spaces. Here are some example matches and the associated replacement output: Note the single space between ?! and wordc which means that wordA wordB wordc will not match, but wordA wordB wordc will. If you're using regex in a web project and would like a quick reference to the regex tokens available, use the regex cheat sheet above as well the tools mentioned to help simplify the regex expression building process.This means match wordA followed by 0 or more spaces followed by wordB, but do not match if followed by wordc. RegexPal also provides you with a larger list of regex examples as well as a regex cheat sheet for reference. ![]()
0 Comments
Leave a Reply. |