I am trying to fetch "portal[portal] @ localhost [127.0.0.1]" info out of "User@Host: portal[portal] @ localhost [127.0.0.1]" I am trying to use negative lookahead for excluding user@host pattern.. like this, "(?!\\b(# User@Host: )\\b)\\b.*" but the problem is, the regex engine does not seem to work for a combination of a special character and a normal character.. if "@" is removed it works fine.. anybody experienced this sort of difficulty?? please help..thanks in Advance.. Xoinki
Regular expressions
Collapse
X
-
Originally posted by xoinkiI am trying to fetch "portal[portal] @ localhost [127.0.0.1]" info out of "User@Host: portal[portal] @ localhost [127.0.0.1]" I am trying to use negative lookahead for excluding user@host pattern.. like this, "(?!\\b(# User@Host: )\\b)\\b.*" but the problem is, the regex engine does not seem to work for a combination of a special character and a normal character.. if "@" is removed it works fine.. anybody experienced this sort of difficulty?? please help..thanks in Advance.. Xoinki
R u using any regex package or in which language u are trying to implement this?
raghuram -
hi,
Thanks for d reply, I am using C++ and i am using PCRE(www.pcre.o rg), I found out another thing.. lets say the pattern to be matched is "@H portal[portal]@localhost" and the regex for extracting "portal[portal]@localhost" i would use "(?!@H).*" meaning: except @H match everything else.. this should match "portal[portal]@localhost" in theory but it is matching "H portal[portal]@localhost" so the combination of alphabets and special characters is causing the problem i found out! I am unable to findout whether this is a problem with PCRE or with my understanding and logic. looking for your help,
XoinkiComment
-
I havent used pcre.Originally posted by xoinkihi,
Thanks for d reply, I am using C++ and i am using PCRE(www.pcre.o rg), I found out another thing.. lets say the pattern to be matched is "@H portal[portal]@localhost" and the regex for extracting "portal[portal]@localhost" i would use "(?!@H).*" meaning: except @H match everything else.. this should match "portal[portal]@localhost" in theory but it is matching "H portal[portal]@localhost" so the combination of alphabets and special characters is causing the problem i found out! I am unable to findout whether this is a problem with PCRE or with my understanding and logic. looking for your help,
Xoinki
I have used Lex to do similar type and i use to use [^ to negate matched patterns.
RaghuramComment
-
[^ is used to negate character classes.. not strings..
If we want to exclude strings then
1) either we need to use negative lookahead as i am trying.
2) or replace the not required pattern.
3) or just use pure C++.
I am trying with 1 not yet went for 2 and 3.. PCRE is same as any other regex..
thnx for replying,
XoinkiComment
Comment