Reputation: 1651
i have a problem here, i have the following string
@Novriiiiii yauda busana muslim @nencor haha. wa'alaikumsalam noperi☺
then i use this regex pattern to select all the string
\w+
however, i need to to select all the string except the word which prefixed with @ like @Novriiiiii
or @nencor
which means, we have to exclude the @word ones
how do i do that ?
ps. i am using regexpal to compile the regex. and i want to apply the regex pattern into yahoo pipes regex. thank you
Upvotes: 1
Views: 1739
Reputation: 89639
A way to do that is to remove words that you don't want. Example:
find: @\w+
replace: empty string
you obtain the text without @abcdef words.
Upvotes: 0
Reputation: 182083
Another option is to include the @
symbol in the word:
[\w@]+
And then add another step in your Pipe to filter out all words that start with an @
.
Upvotes: 0
Reputation: 182083
If you cannot use a negative lookbehind as other answers have already suggested, here's a workaround.
\w
already doesn't match the @
character, so you'd want something like this:
[^@]\w+
But this will (a) not work at the beginning of the string, and (b) include the character before the word in the match. To fix (a), we can do:
(^|[^@])\w+
To fix (b), we parenthesize the part we want:
(^|[^@])(\w+)
Then use $2
or \2
(depending on regex dialect) to refer to the matched word.
Upvotes: 0
Reputation: 7351
This would sole your problem indeed:
[^@\w+][\w.]+
Check this link: http://regexr.com?34tq7
Upvotes: 0
Reputation: 2049
Does this suit your needs?
http://rubular.com/r/uuXvNrUiGJ
[^@\w+]\w+
Upvotes: 0
Reputation: 191819
You can use a negative lookbehind so that if a word is preceded by @
it is excluded. You also need a word boundary before the word or else the lookbehind will only affect the first character.
(?<!@)\b\w+
http://rubular.com/r/ONEl70Am5Q
Upvotes: 2