Login Register






regex question filter_list
Author
Message
regex question #1
what does this regex do b(^\")b


Everyone should learn how to code, it teaches you how to think.

You don't have to be a Genius to know how to code you just need to be determined.

The computer is incredibly fast, accurate, and stupid; man is unbelievably slow, inaccurate, and brilliant; together they are powerful beyond imagination.

Reply

RE: regex question #2
Quote:/ b(^\")b / g
b matches the character b literally (case sensitive)
1st Capturing Group (^\")
  • ^ asserts position at start of the string
  • \" matches the character " literally (case sensitive)
  • b matches the character b literally (case sensitive)
Global pattern flags
  • g modifier: global. All matches (don't return after first match)

https://regex101.com/
(This post was last modified: 07-07-2017, 08:59 PM by Blink.)


(11-02-2018, 02:51 AM)Skullmeat Wrote: Ok, there no real practical reason for doing this, but that's never stopped me.

Reply

RE: regex question #3
i know this but i cant figure what's a valid input in this case.


Everyone should learn how to code, it teaches you how to think.

You don't have to be a Genius to know how to code you just need to be determined.

The computer is incredibly fast, accurate, and stupid; man is unbelievably slow, inaccurate, and brilliant; together they are powerful beyond imagination.

Reply

RE: regex question #4
where you've found this pattern? should it do something special? i havent seen a pattern i this structure.
is it maybe malformed? the only pattern which would look similar would be this one => \b[^\"]+\b
with this one you can look for word boundaries that haven't included double quotes

Reply

RE: regex question #5
As @saegenulled mentioned, it might be malformed. Actually, I'm surprised the majority of regex engines don't throw errors when compiling it.

A caret (^) matches the beginning of a string (or line when the multiline flag is enabled, which it isn't here), so "b" then the beginning of a string always fails.

It could be that whoever wrote this attempted to use it as a negative look ahead (which actually looks like "(?!pattern)") because caret also acts as a negation operator in character classes (e.g. [^xy] matches a character that isn't x or y).

On that note, it could be that the capture group was intended, but the target therein was one non-quote character, meaning the pattern was intended to be the following instead:
Code:
b([^"])b
Which is perfectly valid (no need to escape most things inside character classes), but I don't know what it would be used for without context.
(This post was last modified: 07-16-2017, 06:57 AM by Inori.)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

[+] 1 user Likes Inori's post
Reply

RE: regex question #6
It doesn't look right, I haven't come across anything like that.

As an example, In MySQL, the following returns all values that "start" with the chars B & T:
Code:
'^[BT]'

And If It's hyphenated, It will return all values that "start between" the chars B & T (Inclusive of B & T):
Code:
'^[B-T]'

There's a few other variants, but these are the basics. @Inori has explained your question well.
[Image: AD83g1A.png]

Reply