Re: regular expressions
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Sat, 06 May 2006 21:53:33 +0200
The hyphen is a special character in a set, you have to escape it:
[a-zA-Z'\-]
Jon Paal wrote:
need to verify a string against reg exp. to allow only characters and apostrophe and hyphen
using :
========
Function RegExpValidate(sInput,sPattern) as boolean
Dim RegexObj as Regex = New Regex("regularexpression")
return Regex.IsMatch(sInput,sPattern)
End Function
calling with:
==============
RegExpValidate(MyString,"[a-zA-Z'-]")
but pattern isn't working. any help ???
.
Relevant Pages
- Re: regular expressions
... Function RegExpValidateas boolean ... Dim RegexObj as Regex = New Regex ... Dim IsMatch As Boolean = _ ... You do not need to instantiate 'Regex' because 'IsMatch' is a shared method of the 'Regex' class. ... (microsoft.public.dotnet.languages.vb) - Re: Regular Expression reserved letters
... The problem ist, that e.g.),,are reserved words in regex. ... them in filter expressions i have to escape them with \). ... If, on the other hand, you have a portion of an expresion that must be ... documentation here: <http://java.sun.com/j2se/1.4.2/docs/api/java/util/ ... (comp.lang.java.programmer) - Re: Confusion about String.matches method
... If you wanted a regex you want the two chars \ and n in the regex ... string. ... However, if you do that, Java will think \ is an escape char, so you ... How long did it take after the car was invented before owners understood ... (comp.lang.java.programmer) - Re: Character Escapes Dont Work in VB Regex Replace?
... VB.NET just does not support C# escape sequences, ... not the replace string according to the Character Escapes section of Regular ... as the RegEx class itself is defining this behavior. ... (microsoft.public.dotnet.languages.vb) - Re: Character Escapes Dont Work in VB Regex Replace?
... RegEx.Unescape that will escape & unescape strings for you (including ... supported both in regular expressions and replacement patterns. ... wanted to see if this was a VB specific issue, or the .net regex engine. ... (microsoft.public.dotnet.languages.vb) |
|