Link to home
Start Free TrialLog in
Avatar of Sam OZ
Sam OZFlag for Australia

asked on

VB.NET function to check starting substring

I am looking for VB.NET function to check if a string is starting with anything between 500 to 599
 

Example strings
   523 Doc1
   Doc1
   5002Doc2
   Document523SubDoc
   522-Doc3

The valid strings from the above are
   523 Doc1
   522-Doc3
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sam OZ

ASKER

Thanks . But I don't need this to come as an array . At one time only one string is taken ( For example Doc1).  The function just need to check the rule of 5xx and return true or false
I hope the StartNo variable is god enough
yup, similar concept applied for one string, hence use the part mentioned below should be good enough:

Dim startNo As String = Regex.Match(value, "^\d+").Value
            Integer.TryParse(startNo, num)

Open in new window


and then refer to the value of num