1

I need to get the values of img= via= title=. Is there a smart way to do it or does it just require a lot of split and join?

http://www.example.com/#section/img=http://example.org/mypic.jpg/via=example.org/blog/pictures/title=Hello-World

The content will be always different. Thanks

1 Answer 1

3

have you tried using regular expressions? It seems like the perfect fit for this.

Basically I would separate the http://www.example.com/#section/ from img=http://example.org/mypic.jpg/via=example.org/blog/pictures/title=Hello-World

then use another regex to split the three different values most uris use another character that can act as a separator. look at http://en.wikipedia.org/wiki/URI_scheme

Semicolon: key1=value1;key2=value2;key3=value3

Ampersand: key1=value1&key2=value2&key3=value3

this makes creating regular expressions easier, because you look for anything between the separators.

you would then end up with an array of three strings key1=value1 key2=value2 and key3=value3 you can do another regex where you separate on the = and end up with an array that holds the key/value pair.

If you know your regular expression well, you might be able to do it with fewer expressions.

the tool I always use is http://regexpal.com to craft my expressions. but you might be able to find something in http://regexlib.com/ though they probably utilize the & or ;

Sign up to request clarification or add additional context in comments.

1 Comment

How to get the value of title= ? For the rest I'm using this code: var inbetween:RegExp = /img=(.*?)\/via/g; var imgmatch:Object = inbetween.exec(my.text); var imgpath = imgmatch[1];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.