MST

星途 面试题库

面试题:Bash字符串模式匹配及替换

假设有一个字符串变量str="This is a test string with some numbers like 123 and 456.",编写Bash脚本,使用正则表达式匹配字符串中的所有数字,并将其替换为'[NUMBER]',最后输出替换后的字符串。
33.6万 热度难度
编程语言Bash

知识考点

AI 面试

面试题答案

一键面试
str="This is a test string with some numbers like 123 and 456."
echo ${str//[0-9]*/[NUMBER]}