regex - Coldfusion ReReplace 电话号码重新格式化

标签 regex string coldfusion

我正在尝试从 .pdf 文件重新格式化电话号码目录。
我提取了所有文本,所有电话号码都是这种格式( 555 ) 555 - 555我想把它们放在这个 5555555555 ,然后是 <br>我想这样做#ReReplace(Directory, "\(.*?.\).*?.\-.*?", "", "all")#但它留下了空格,我无法获得 <br>在。
我在错误的轨道上吗?

是否可以使用 Rematch 返回一个将字符串拆分的数组,例如

["some string ( 555 ) 555 - 555", "some string ( 555 ) 555 - 555", "some string ( 555 ) 555 - 555"] 

最佳答案

试试这个 - 使用捕获组和反向引用,我们可以提取数字

#ReReplace(Directory, "\(\s*(\d+)\s*\)\s*(\d+)\s*-\s*(\d+)", "\1\2\3<br>", "all")#

关于regex - Coldfusion ReReplace 电话号码重新格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27554512/

相关文章:

c++ - 匹配除双引号以外的任何字符

c++ - C/C++ : Optimization of pointers to string constants

string - Perl:从文件读取后如何检查数组列中单词的最大宽度?

excel - 格式化 lucee 电子表格时出错 : The maximum number of cell styles was exceeded

coldfusion - 更改 Coldfusion 上附件的文件名

ColdFusion 对象到字符串

regex - powershell:删除字符串中的字符

java - 如何反转整个句子的字符大小写?

python - 与 MatchObject.group() 相关的 re.sub() 错误

c# - C#中字符串转int并测试成功