1
I have several types of texts, such as: $ticker="08.070.838/0001-63.offset(1)"
.
I want to capture the text and the digit, if any, which is in parentheses to turn it into the form "08.070.838/0001-63.offset+1"
.
I’m trying for the regex '(\S*)\((\d)\)'
used in php by preg_match
as follows:
if(preg_match('(\S*)\((\d)\)', $ticker, $match)) $ticker=$match[0]."+".$match[1];;
But it is returning the error message:
Warning: preg_match(): Unknown Modifier '\'.
Would anyone know what’s wrong with any of these \
?
What language are you using?
– R.Santos
I’m trying to use regular expressions by PHP
– Christian
Matcher textoParenteses = Pattern.compile("(.)").matcher(textoOrignal)
String textNovo = textoParenteses.replace('(','+').replace(')','')
This in Java in the case, I believe that to adapt to PHP– R.Santos
Try
$res = preg_replace('\((?=\w*\d*\))', '', $ticker);
demo and$res = preg_replace('\)(?=$)', '+', $ticker);
demo to replace the parents.– danieltakeshi