\$\begingroup\$
\$\endgroup\$
I need to remove all the numbers appearing inside square braces such as [9] , [2] , ....
This is my regex:
"(?:\[\d*\])"
Which is working fine. But I am totally new to regex so let me know if is there a better regex that can be used.
1 Answer 1
\$\begingroup\$
\$\endgroup\$
2
You don't need the grouping here, and also you'd want to match for 1 or more digits: "\[\d+\]"
answered May 26, 2016 at 6:52
-
\$\begingroup\$ that was actually my first attempt but i don't know why i made it complex BTW thanks \$\endgroup\$mak– mak2016年05月26日 07:09:04 +00:00Commented May 26, 2016 at 7:09
-
\$\begingroup\$ The problems with regexen is that they're easier to write than to read. Which means that for simple regexen it might be a good idea to start over instead of tweaking an existing solution. \$\endgroup\$Anselm Helbig– Anselm Helbig2016年05月26日 07:45:17 +00:00Commented May 26, 2016 at 7:45
default