![]() |
|
regex question - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Coding (https://sinister.li/Forum-Coding--71) +--- Thread: regex question (/Thread-regex-question) |
regex question - Vi-Sion - 07-07-2017 what does this regex do b(^\")b RE: regex question - Blink - 07-07-2017 Quote:/ b(^\")b / g https://regex101.com/ RE: regex question - Vi-Sion - 07-07-2017 i know this but i cant figure what's a valid input in this case. RE: regex question - saegenulled - 07-16-2017 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 RE: regex question - Inori - 07-16-2017 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([^"])bRE: regex question - mothered - 07-16-2017 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. |