Avatar of Wayne Barron
Wayne Barron
Flag for United States of America asked on

asp classic find word in string and get its value

Hello All;

theString = "A lot of information is here, and we just want to get this one string and post back it''s data to the page. We are hunting for [imge:filename.jpg] and then we are going to work with it on the page."

OK, in the "theString" above, we need to first find
[imge:filename.jpg]
And then we need to get the value.
filename.jpg

I need to return the value (not a number, but the actual value) of the name.
filename.jpg

Any idea's on this one?
Carrzkiss
ASPVB Script

Avatar of undefined
Last Comment
Wayne Barron

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ryan Chong

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Wayne Barron

ASKER
Nice, thanks, Ryan.

I changed it up a little, to make sure that it only grabs that tag.

fileName = Split(Split(Split(theString, "[image") (1), "]") (0), ":") (1)


Works great.
Much appreciated.

Wayne
Wayne Barron

ASKER
Hey, Ryan.

How would you bypass this function IF there i no image tag in the string?

Example

Code with image tag. (This works great)
<%
theString = "A lot of information is here, and we just want to get this one string and post back it''s data to the page. We are hunting for [image:filename.jpg] and then we are going to work with it on the page."
fileName = Split(Split(Split(theString, "[image") (1), "]") (0), ":") (1)
response.write "theString = " & theString & "<br>fileName = " & fileName
%>

Open in new window


Code WITHOUT image tag. (Subscript out of range: '[number: 1]')
<%
theString = "This string does not have an image tag in it, so it is not going to result in nothing from the SPLIT."
fileName = Split(Split(Split(theString, "[image") (1), "]") (0), ":") (1)
response.write "theString = " & theString & "<br>fileName = " & fileName
%>

Open in new window

Ryan Chong

How would you bypass this function IF there i no image tag in the string?
we will need to have a pattern for parse the string. so we gonna built that logic for text extraction.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Wayne Barron

ASKER
Hey, Ryan.
I took a different path.
Instead of Generating the code
[image:imagename.jpg]

Open in new window

I am generating the Image and users name.
[image:username|imagename.jpg]

Open in new window

And then processing it out in the code.
So, this works.

I was looking at the way I was trying. (The reason for the thread)
And I saw that it would be resource intensive, and it would only do one tag.
What if there were multiple tags.

So, I decided that the best thing to do would be better something that is best on the system, and better on coding as well.
Would be to just add the user's name to the image tag, and process it with the page, instead.

Thanks for your assistance once again.
I will be able to use your code, provided here for a future project.

Take care, Ryan.
Wayne
Ryan Chong

Noted, and it seems there's a lot of excitements in your projects. All the best!
Wayne Barron

ASKER
Hey, Ryan.
Oh, Yeah!
There is a lot of excitement about this project, as it is a MAJOR update to the site.
However, the other projects. Now, that one has me jumping for joy and doing flips.
Something I have been wanting to do since I first started doing this thing we call, database driven web design.

Have a good one, Ryan.
Wayne
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.