Regex String Between Underscore
I need to get the markings between the underscores, for example: Com_x0020_este_x002C__x0020_texto Com_x0020_este_x002C_ _x0020_texto Thank you!
Solution 1:
What you are looking for it preg_replace documentation can be found here: http://php.net/manual/en/function.preg-replace.php and the logic you are looking for it as follows:
PHP Version:
$string = "Com_x0020_este_x002C__x0020_texto";
print preg_replace('/_(.*?)_/', " _$1_ ", $string);
Javascript Version:
var $string = "Com_x0020_este_x002C__x0020_texto";
alert($string.replace(/_(.*?)_/g," _$1_ "));
Result: Com _x0020_ este _x002C_ _x0020_ texto
Solution 2:
You can try this, if I understand the question correctly: /_(.*?)_/g
See https://regex101.com/r/H3exx4/1/ for an example.
Post a Comment for "Regex String Between Underscore"