Hi guys! I need a regex that checks if my string has the following format: 5XXXX/XX/XX.
Basically my string will always start with number 5 and all Xs can be any numbers. The whole string has 11 characters. Ex: 51234/12/34
Can you please advise? Thanks in advanced!
I need to have that exact format splitted by “/”. So first 5XXXX then / then XX then / then XX. First group must start with 5 and have 5 characters no more no less, second group 2 characters no more no less and third 2 characters no more no less.
Not working. It checks all of them true and i also have this format XXXXXXXX so it should check false for it
Actually there is digit check but it is getting considered as html
System.Text.RegularExpressions.Regex.Match(yourString,"[5](\d){0,5}[/](\d){0,2}[/](\d){0,2}").Value
It takes in consideration the ones with this ormat also 5XXXXXXXXX/XX/XX or 5XXXXXXXXXXX/XX/XX so no good
Same as first one so no good
I don’t understand what you mean.
How you are trying it? Which case it is not working?
Explain your issue in detail…About what is happening…
For example with your Regex this string matches 5XXXX/XX/XXXX and this 5XXXX/XX/XXX and this one 5XXXX/XX/XXXXXX and it shouldn’t. Only string with this format 5XXXX/XX/XX should match.
Hi @RaduNRV
Please try the below regex and let me know whether it meets your expectation.
Regex: ^5.{4}|/\d{2}
Feel free to reach us at any time if you have doubts. Thanks.
Happy Automation
First use [5](\d){4}[/](\d){2}[/]\d{3}
this expression if anything coming means it’s wrong format or else use [5](\d){4}[/](\d){2}[/](\d){2}
to get correct value.
Because regex will give you a matching value and you need to check if it is expected.
How about this… @RaduNRV
Above pattern will pick only as you mentioned anywhere in your text.
Hope this helps…
Works perfectly. Many thanks !!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.