Click here to Skip to main content
14,422,431 members
Rate this:
Please Sign up or sign in to 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 23:34pm
Comments
phil.o 13-Jan-20 5:17am
   
"fantancistics" sounds like a fantastic STD.
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
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 4 days ago
   
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 4 days ago
   
And?
What have you tried?
Where are you stuck?
What help do you need?
Akshay malvankar 4 days ago
   
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
OriginalGriff 4 days ago
   
At the risk of repeating myself:
"And?
What have you tried?
Where are you stuck?
What help do you need?"

You want to try answering some - or preferably all - of those questions?
Akshay malvankar 4 days ago
   
i want this validation 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

i tired \d{10}

this validate only 10 number from string e.g 5695748596

i want expression that validate number and special charater between them e.g 25564@$55464
OriginalGriff 4 days ago
   
"I want", "I want", "I want" ...
What have *you* tried, other than a regex to solve a different problem?

You've asked 32 questions now, and they are all the same: "I want" with little or no sign of effort or willingness to learn coming from you. That's characteristic of a "Help Vampire" rather than somebody who is trying to improve. Honestly? You will get a faster result by learning some of this stuff yourself instead of expecting others to do it for you.

So I repeat myself again:
"And?
What have you tried?
Where are you stuck?
What help do you need?"
And this time, try to solve it first - and then ask for help.
Rate this:
Please Sign up or sign in to vote.

Solution 3

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.
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100