✅ – satvvrn – 15-47 Jun 12
I need a little Regex help. Consider the following string:
x..y..x..z
. I want to match x..y
and x..z
separately. x(.+?)z
matches x..y..x..z
which is Not what I want. What Regex pattern would match only x..z
?13 Replies
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
But that would match both
x..y
and x..z
. I want a Regex that discards/does not match x..y
nor x..y..x..z
, only x..z
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
That would work for this case, but I see I might've made the example too abstract. In my specific case I have the following string:
I effectively want to match
Address: 456 Test Ave (Work)
. "x" is "Address:", "y" is "(Home)" and "z" is "(Work)"
[^x]
wouldn't work in my case.Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
The negative lookahead worked, thanks!
This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1250476632045785203
Followup question: Apparently, the example above only works if there's a newline in the middle. When removing the newline, it starts not working again:
How would I fix?
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
It doesn't change anything, though
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
That seems to make it work. I ended up using
Address: ((?:(?!Address:).)*) \(Work\)
to have $1
be just the full address. Thanks again!This thread hasn’t had any activity in 36 hours, so it’s now locked.
Threads are closed automatically after 36 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1250476632045785203