Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want regex expression in vb.net that checked 10 digit mobile number from giving string for e.g text is " this review is cutomer care \\ 9856247485 form product is good and fantancistics " . i want regex experssion that identified above text contain 10 digit mobile number

What I have tried:

i tried many think but it not working
Posted
Updated 12-Jan-20 22:34pm
Comments
phil.o 13-Jan-20 5:17am    
"fantancistics" sounds like a fantastic STD.

That's trivial:
\d{10}
If you are going to play with Regexes, then get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.
 
Share this answer
 
Comments
Akshay malvankar 13-Jan-20 5:42am    
Dim text As String = " Hey guys, I recently brought this bike from jaipur cutomer 8547582496 honda showroom.after documentation process, I drove my home that is approximately 8 km away from that store and engine and silencer get heated terribly.I thought it may be due to first drive.Next day after a ride of 8 km it "
Dim pattern As String = "/^\d{10}$/"
If Regex.IsMatch(review, pattern) Then
Return False
End If

Not working
OriginalGriff 13-Jan-20 6:08am    
Of course it isn't working.
You added "start of line or string" and "end of line or string" to the match I gave you, which means that the requirement becomes "the whole string must be just ten digits and nothing else". Since there is other stuff in there, it doesn't match ...

Seriously, get a copy of Expresso - it would have explained that to you ...
Akshay malvankar 15-Jan-20 6:59am    
i want regex expression that find special character in between number for e.g 78459&*#$@$$<><85
above number contain special character in between number . i want regex that checked 8 digit number along with special character
OriginalGriff 15-Jan-20 7:05am    
And?
What have you tried?
Where are you stuck?
What help do you need?
Akshay malvankar 15-Jan-20 23:26pm    
above validation failed when i 78459&*#$@$$<><85 this number , i want this also be cheked and also it failed in "1656646646 avsnns absbs abss", i want both condition to be cheked
As OG already answered: \d{10}

Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx: Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
This site also show the Regex in a nice graph but can't test what match the RegEx: Regexper[^]

[Update]
If you read carefully the RegExs, you will see that /^\d{10}$/ and \d{10} are different and thus match different strings. Read documentation to understand what is the difference.
 
Share this answer
 
v2
Comments
Akshay malvankar 13-Jan-20 5:46am    
Dim text As String = " Hey guys, I recently brought this bike from jaipur cutomer 8547582496 honda showroom.after documentation process, I drove my home that is approximately 8 km away from that store and engine and silencer get heated terribly.I thought it may be due to first drive.Next day after a ride of 8 km it "
Dim pattern As String = "/^\d{10}$/"
If Regex.IsMatch(review, pattern) Then
Return False
End If

Not working
Patrice T 13-Jan-20 5:56am    
Use Improve question to update your question.
So that everyone can pay attention to this information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900