regex


How to check character repetition in string?


Hi guy's I am new to the regex and i am trying the create the expression for the pattern of the string value the rules are as below
1) String must start with the 'O' or 'T'
2) After that there must be 9 digits
3) After that there must be 'T'
4) After that alphanumeric string with specs and numbers and character'D' these can repeat any number of time in string of length 25
5) Then character 'O'
6) Then string with numbers and spaces of length 5
However i am done with the all the conditions but for the condition 4 i am not sure how to do it because it can repeat 'D' any number of times in given string with length 25. Write now i have adjusted the optional 'D' at every place where it present in the string that is kind of very lengthy regex so I was hoping some one would help me with condition 4 .Any help would be great.
The string to 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 am confused about this part of regex
(?:T\s*\d*\s*[0-9DO ]\d*\s*[OD0-9 ]\s*\d*[D0-9]\s*\d*[0-9OD ]\d*)
is this the correct way ?
You can try this for the all your matching pattern ,
(O|T)\d{9}T[DO \d]{0,25}O[\d ]{5}
Condition 4 is not clear.
(O|T)\d{9}T[D\d]{25}O[\d ]{5}
Maybe is D{0,25}. it means D repeated 0~25 times.

Related Links

Sed Match Number followed by string and return Number
Perl matching string with mix of alphanumeric,_ and any number of square braces [closed]
Bash: extract the scheme and host part from a URL string
RexExp find a word within a list of words that are within a parenthesis
Converting EBNF to Regular Expression
Regex rule - allow empty field or special format [duplicate]
Using powershell to search for a pattern
Check odd number of a certain character
Regex: unexpected double replacement [duplicate]
How do I use the sed command to remove all but the first three characters in a line?
“OR” operator in regex, in express routing
Regex add tag to subtitles
Regex to extract second word from URL
Regular expressions combined with list for numbers written as words
Wordpress .htaccess
Disallow Whitespace Regex

Categories

HOME
math
ssis
validation
robotframework
watson
anylogic
path
asana
prometheus
xquery
application-cache
spi
jbpm
sweetalert
google-adwords
http2
r-caret
base
superfish
zebble
group-by
apache-kafka-streams
gitlab-ci-runner
swig
hp-alm
jruby
windows-applications
accelerated-mobile-page
jcrop
memorystream
reformatting
ocean
kprobe
gecko
sqlite.swift
apex-code
capstone
double-click-advertising
draggable
ubuntu-server
solid-principles
windows-scripting
visualsvn-server
wso2iot
hawkular
stateful
sdcc
rtems
distributed-lock
keyboard-maestro
ms-jet-ace
ctl
replaygain
tpl-dataflow
sshd
catalina
netbeans-7
gpt
swift-package-manager
lapply
sizing
statistics-bootstrap
sliding
schematiq
multiple-files
sqlj
ubiquity
multiscreen
equinox
dhc
scribe
typesafe-activator
mui
dojo.gridx
twill
declspec
scala-pickling
couchrest
xcache
memoization
xhtml-transitional
globbing
asp.net-authentication
tempo
12factor
sender
cakephp-2.1
teamcity-7.0
proxy-classes
objcopy
ruby-1.9.2
data-oriented-design
closest
nscollectionviewitem
syncml
pastebin
keylogger
chickenfoot
msn-messenger
project-settings
gendarme
resharper-4.5
sharepoint-feature
shareware
greensoftware
versant-vod

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App