正则表达式匹配以某些字符开头并跟随一些符号的字符串
Regular expression to match a string starting with some characters and following with some symblos
我想匹配以字符序列 49
开头的字符串。我要评估的字符串将类似于 49/1.0 or 49/2.0
等。如果我使用 ^49
,它与我收到的字符串不匹配(即:49/1.0
)。如果我只收到 49XX
,我的表达式与字符串匹配。我不确定 49
字符后面的符号是什么。
如何为此定义正则表达式?
试试这个: ^49.*
这个正则表达式。
解释
^ # start of the string;
49 # match first 49
.* # match any char in zero to multiple time..
我想匹配以字符序列 49
开头的字符串。我要评估的字符串将类似于 49/1.0 or 49/2.0
等。如果我使用 ^49
,它与我收到的字符串不匹配(即:49/1.0
)。如果我只收到 49XX
,我的表达式与字符串匹配。我不确定 49
字符后面的符号是什么。
如何为此定义正则表达式?
试试这个: ^49.*
这个正则表达式。
解释
^ # start of the string;
49 # match first 49
.* # match any char in zero to multiple time..