正则表达式从字符串中删除括号 [英] RegEx remove parentheses from string

查看:71
本文介绍了正则表达式从字符串中删除括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有:

string = (1000.00)

如何使用正则表达式去除括号并得到1000.00的输出?

How can I use regex to remove the parentheses and get the output as 1000.00?

谢谢

推荐答案

试试这个正则表达式:

s/([()])//g

简要说明:[] 用于为任何正则表达式创建字符集.我在这个特殊情况下的字符集()组成.所以总的来说,将 () 替换为空字符串.

Brief explanation: [] is used to create a character set for any regular expression. My character set for this particular case is composed of ( and ). So overall, substitute ( and ) with an empty string.

这篇关于正则表达式从字符串中删除括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆