Wildcard String Search

  • Thread starter Thread starter Cliff
  • Start date Start date
C

Cliff

Hello

I'm trying to search for each instance of a string (using wildcards) in another string. I know there is the Like operator, but it seems to be work with booleans and I want to define a string variable.

I tried strPdfFileName = strPdfFileName Like "########.pdf"

I'm sure there's a better string methd to better accomplish what I'm doing here.

Thans in advance - Cliff


Function ExtractPdfFileNames(ByVal strSourceText As String) As ArrayList

Dim arrFoundPdfFileNames As New ArrayList()
Dim strPdfFileName As String

'define what a pdf filename looks like
strPdfFileName = 'here is where I want to define ".pdf" and 8 digits to the left (i.e. "13567849.pdf") _
or even any word ending in ".pdf"

'copy pdf filenames from source text into arraylist
For Each strPdfFileName In strSourceText
arrFoundPdfFileNames.Add(strPdfFileName)
Next

'return the results
Return arrFoundPdfFileNames

End Function
 
Thanks for the help, but I must be totally dense. I tried working with the
MSDN example below, but the Capture Class example seemed way too complicated
for my needs. i.e. I couldn't decipher:

Dim pat As String = "(?<1>\w+)\s+(?<2>fish)\s*"

I don't know if anyone can give me a really simple example from my original
code below.

Thank you! - Cliff


Cor said:
Hi Cliff,

Have a look at the regular expressions for that

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemtextregularexpressions.asp

I hope this helps

Cor
Hello

I'm trying to search for each instance of a string (using wildcards) in
another string. I know there is the Like operator, but it seems to be work
with Booleans and I want to define a string variable.

I tried strPdfFileName = strPdfFileName Like "########.pdf"

I'm sure there's a better string methd to better accomplish what I'm doing
here.

Thanks in advance - Cliff


Function ExtractPdfFileNames(ByVal strSourceText As String) As ArrayList

Dim arrFoundPdfFileNames As New ArrayList()
Dim strPdfFileName As String

'define what a pdf filename looks like
strPdfFileName = 'here is where I want to define ".pdf" and 8 digits
to the left (i.e. "13567849.pdf") _
or even any word ending in ".pdf"

'copy pdf filenames from source text into arraylist
For Each strPdfFileName In strSourceText
arrFoundPdfFileNames.Add(strPdfFileName)
Next


'return the results
Return arrFoundPdfFileNames

End Function
 
Back
Top