Hi guys
I have a string (read from a text file), and i need to be able to pull out the value in the quotation marks. For example:

if my string is <img src="hello.jpg">

, I need to return hello.jpg.

The tough part is that there can by any number of spaces (including 0) in between img and src, between src and = , and between = and the first quotation mark.

Do I need to use wildcards?

That was hard to describe... hope someone understood my problem.
Thanks!

Your best bet would be to use the regular expression object to find matches to the pattern you want. An example script is included below.

<%
dim sampletext, objRegExp, SearchPattern, ReplacePattern, matches

sampletext = "<img src=""hello.jpg"">"

'// enter the search pattern here
SearchPattern = """" ' opening quote
SearchPattern = SearchPattern & "(.*?)" ' any number of text characters
SearchPattern = SearchPattern & """" ' closing quote

'// create a new instance of the regular expression object
Set objRegExp = New RegExp

objRegExp.Pattern = searchpattern ' apply the search pattern
objRegExp.Global = True ' match all instances if the serach pattern
objRegExp.IgnoreCase = True ' ignore case

'// find all occurences of the search pattern in the sample text
Set matches = objRegExp.execute(sampletext)

If matches.Count > 0 Then ' there was at least one match to the search pattern
  For Each match in matches
    Response.Write replace(match.Value, """", "") & "<br>"
  Next
Else ' there were no matches found
  Response.Write "<B>" & objRegExp.Pattern & "</B> was not found in the string: <B>" & StringToSearch & "</B>."
End If

'// releast the reg exp object
Set objRegExp = nothing
%>

if you know that it should always be only two question marks, here is something a little easier

<%

inputString = "<img src=""hello.jpg"">"
inputString = Replace(inputString, """", Chr(0))

strArray = Split(inputString,Chr(0))

if ubound(strArray) = 2 then
 resultString = response.write strArray(1)
else
 ' psuedocode 
 ' something went wrong, so handle problem
end if


%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.