不超过一个连续字符出现的正则表达式 由 rut发布于 2020-04-09 05:59:30 我正在寻找仅在字符串中连续出现2个连续字符时才匹配的正则表达式。 例如: 1123456-匹配 1122345-不符 1121125-不匹配 1234567-不符 1112345-不匹配 当前具有此正则表达式:([0-9])\ 1 {1,},但它也匹配1122345,这不是我所需要的
这awk做到了:
Setting the field to empty string (
""
) you can read each line character-wise! If characteri
equals characteri+1
, then incrementd
. Ifd==1
, the string is printed.从您的样本中:
它输出: