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
LVL 31
Wayne BarronAuthor, Web DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
a quick and dirty solution:

<%

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."

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

response.write "theString = " & theString & "<br>fileName = " & fileName

%>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wayne BarronAuthor, Web DeveloperAuthor Commented:
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
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
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

0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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.
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
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
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
Noted, and it seems there's a lot of excitements in your projects. All the best!
0
Wayne BarronAuthor, Web DeveloperAuthor Commented:
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
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.