regex - How to check character repetition in string? -
hi guy's new regex , trying create expression pattern of string value rules below
1) string must start 'o' or 't' 2) after there must 9 digits 3) after there must 't' 4) after alphanumeric string specs , numbers , character'd' these can repeat number of time in string of length 25 5) character 'o' 6) string numbers , spaces of length 5
however done conditions condition 4 not sure how because can repeat 'd' number of times in given string length 25. write have adjusted optional 'd' @ every place present in string kind of lengthy regex hoping 1 me condition 4 .any great.
the string match -->
t011600062to51d45d0399d0o 1807
the latest regex -->
(?x)((?:[ot]\d{9})(?:t\s*\d*\s*[0-9do ]\d*\s*[od0-9 ]\s*\d*[d0-9]\s*\d*[0-9od ]\d*)(?:[o]\s*\d*)\b)
i confused part of regex
(?:t\s*\d*\s*[0-9do ]\d*\s*[od0-9 ]\s*\d*[d0-9]\s*\d*[0-9od ]\d*)
is correct way ?
you can try matching pattern ,
(o|t)\d{9}t[do \d]{0,25}o[\d ]{5}
Comments
Post a Comment