Link to home
Start Free TrialLog in
Avatar of luca345
luca345

asked on

Simulate 'Like' operator with RegEx

Hi

I need  to simulate the vb 'like' operator with a new  equivalent function.

I was try to use this function:

//
  Public Shared Function LikeOp(ByVal inputString As String, ByVal PatternString As String) As Boolean

        Return System.Text.RegularExpressions.Regex.IsMatch(inputString, PatternString)

    End Function
//

but return different result and is not the exact 'like' equivalent.

Someone can please help me to fix  this function ?

Best Regards
Avatar of Pierre François
Pierre François
Flag of Belgium image

You can find a C# function that permits to compare two words (typically names) and see if they sound alike. See: http://www.csharphelp.com/2006/11/c-soundex-utility/

This function is called soundex. Two strings w1 and w2 look alike when they have the same soundex value: soundex (w1) == soundex (w2).

Hoping this helps.
Why can't you use the LIKE operator directly?
Public Shared Function LikeOp(ByVal inputString As String, ByVal PatternString As String) As Boolean

	Return (inputString LIKE PatternString)

End Function

Open in new window

Avatar of luca345
luca345

ASKER

I need to operate in VB and C# in the some mode.

C# don't have the 'like' operator but in my vb project there are many calls.

I need to fix the LikeOp function with some result of original 'like'.

I don't known how is difficoult do this.

Can you help me please ?
You could create a VB.NET DLL that contains the LikeOp method (using the LIKE operator), and then you can reference it on your other projects.
Avatar of luca345

ASKER

Yes, But create a DLL for only one function is not good idea.

I think there are alternatives, I hope.
ASKER CERTIFIED SOLUTION
Avatar of wdosanjos
wdosanjos
Flag of United States of America 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 luca345

ASKER

This is a solution.

I have already thinked about it.

This is and VB6 library and in the future will be certanly removed.

I have recently migrated from VB6 to vB.net and for this reason I like to use only .NET library.

If there are not other solutions this can be good.
Avatar of luca345

ASKER

Someone can confirm if:

Microsoft.VisualBasic.CompilerServices.LikeOperator.LikeString

is supported by mono project please ?
Avatar of luca345

ASKER

I Have find myself an equivalent function that use regex.

However thank you.
Avatar of luca345

ASKER

Good