Quantcast
Channel: Regular Expression to find a string included between two characters while EXCLUDING the delimiters - Stack Overflow
Browsing latest articles
Browse All 14 View Live

Image may be NSFW.
Clik here to view.

Answer by stevec for Regular Expression to find a string included between two...

Here's a general example with obvious delimiters (X and Y):(?<=X)(.*?)(?=Y)Here it's used to find the string between X and Y. Rubular example here, or see image:

View Article



Answer by Luis Febro for Regular Expression to find a string included between...

Most updated solutionIf you are using Javascript, the best solution that I came up with is using match instead of exec method.Then, iterate matches and remove the delimiters with the result of the...

View Article

Answer by Jamaxack for Regular Expression to find a string included between...

Here is how I got without '[' and ']' in C#:var text = "This is a test string [more or less]";// Getting only string between '[' and ']'Regex regex = new Regex(@"\[(.+?)\]");var matchGroups =...

View Article

Answer by techguy2000 for Regular Expression to find a string included...

I wanted to find a string between / and #, but # is sometimes optional. Here is the regex I use: (?<=\/)([^#]+)(?=#*)

View Article

Answer by Stieneee for Regular Expression to find a string included between...

[^\[] Match any character that is not [. + Match 1 or more of the anything that is not [. Creates groups of these matches.(?=\]) Positive lookahead ]. Matches a group ending with ] without including it...

View Article


Answer by null for Regular Expression to find a string included between two...

This one specifically works for javascript's regular expression parser /[^[\]]+(?=])/gjust run this in the console var regex = /[^[\]]+(?=])/g;var str = "This is a test string [more or less]";var match...

View Article

Answer by Zanon for Regular Expression to find a string included between two...

If you are using JavaScript, the solution provided by cletus, (?<=\[)(.*?)(?=\]) won't work because JavaScript doesn't support the lookbehind operator.Edit: actually, now (ES2018) it's possible to...

View Article

Answer by A. Jesús for Regular Expression to find a string included between...

I had the same problem using regex with bash scripting.I used a 2-step solution using pipes with grep -o applying '\[(.*?)\]'first, then'\b.*\b'Obviously not as efficient at the other answers, but an...

View Article


Answer by Nico for Regular Expression to find a string included between two...

If you need extract the text without the brackets, you can use bash awkecho " [hola mundo] " | awk -F'[][]''{print $2}'result:hola mundo

View Article


Answer by Cătălin Rădoi for Regular Expression to find a string included...

To remove also the [] use:\[.+\]

View Article

Answer by powtac for Regular Expression to find a string included between two...

PHP:$string ='This is the match [more or less]';preg_match('#\[(.*)\]#', $string, $match);var_dump($match[1]);

View Article

Answer by Xetius for Regular Expression to find a string included between two...

You just need to 'capture' the bit between the brackets.\[(.*?)\]To capture you put it inside parentheses. You do not say which language this is using. In Perl for example, you would access this using...

View Article

Answer by cletus for Regular Expression to find a string included between two...

Easy done:(?<=\[)(.*?)(?=\])Technically that's using lookaheads and lookbehinds. See Lookahead and Lookbehind Zero-Width Assertions. The pattern consists of:is preceded by a [ that is not captured...

View Article


Regular Expression to find a string included between two characters while...

I need to extract from a string a set of characters which are included between two delimiters, without returning the delimiters themselves.A simple example should be helpful:Target: extract the...

View Article
Browsing latest articles
Browse All 14 View Live




Latest Images