Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RegEx -- String Dismissal
- If you want to match a word A in a string and not to match a word B. For example: If you have a text:
- 1. I have 3 pets - 2 dogs and a cat
- 2. I have 1 pet - a dog
- If you want to search for lines of text that HAVE a dog for a pet and DOESN'T have cat you can use this regular expression:
- ^(?=.*?\bdog\b)((?!cat).)*$
- It will find only second line:
- 2. I have 1 pet - a dog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement