regexmatch.dev
Explore
Open main menu
Save & Share
Facebook
Twitter
Tumblr
E-Mail
Pinterest
LinkedIn
Reddit
Grab double or single quoted text, escape aware
Published on Tue Mar 01 2022
^$ are only added for the test cases, handles escapes and the closing \\" situation
Regex
Test String
'hello world' 'here\'s my foo' 'Im at my friends\' "\"hello\", he said " "that's a backslash: \\"
Additional matching regexes for
Grab double or single quoted text, escape aware
Grab double or single quoted text, escape aware
^$ are only added for the test cases, handles escapes and the closing \\" situation
Match quoted strings, ignoring escaped quotes
Matches single or double quoted strings, and ignores backslash-escaped quotes within the string.
Escape Special Characters
Escapes special characters. Reference: http://www.php.net/manual/en/function.mysql-real-escape-string.php
parsing CSV file
It correctly handles simple values, empty values, and quoted values with commas inside.
Isolate string in double or single quotes
Isolate strings inside double or single quotes
Inside single quotes, escape aware
Allows the single quote to be escaped, handles the \\' situation
Split quotes and single words
Find " and ' quoted strings and "orphaned"/single words in a string
Outside Quotes
match any string outside of single or double quotes
Get inside single/double quotes
Get everything inside single/double quotes and ignoring escaped ones
Match multiline comments /* ... */
It won't match single line comments like this one: //* This comment won't be match */ ^ see the double / Works in PHP without the g modifier.