Let's say I have the following String / Product / 976935 /
How would I do a regex to return only the numbers between the second and third bar?
The number of numbers varies so it does not matter to return only the numbers
Let's say I have the following String / Product / 976935 /
How would I do a regex to return only the numbers between the second and third bar?
The number of numbers varies so it does not matter to return only the numbers
If it's always product, you can do:
/produto/(\d+)/
If the prefix changes depending on the case use:
/(\w+)/(\d+)/
Note that I also captured the prefix in this case.
Depending on the language it may be necessary to add leaks to the bars. Change% with% by% with%.
If you want to remove any text, simply use the following expression
"[^0-9]" ou "[^\d]"
If it is / product / 976935 / it will return 976935 , but if it is / product / 976935/1 it will return tbm number 1 and would be 9769351
In Java I think it would look something like this:
var soNumero = soNumero.replaceAll("[^0-9]","");
or
var soNumero = soNumero.replaceAll("[^\d]","");