Need help in RegEx

J

JM

Hi,

I don't know much about regex and need a help. I have got :

1. Original string: http://www.rediff.com/general/story/9622681/id=123

2. and I want to convert it into
http://www.rediff.com/general/story/print/9622681/id=123

See the "print". This is the only additional directory in #2.

Basically I need a way by which I can apply a RegEx to original string
(i.e. #1) and should get the desired URL as in #2.

And if this can be done in one step that would be great as I need to
create a function which should do this conversion for all these kind of
URLs.

Thanks
JM
 
B

Bruce Wood

JM said:
Hi,

I don't know much about regex and need a help. I have got :

1. Original string: http://www.rediff.com/general/story/9622681/id=123

2. and I want to convert it into
http://www.rediff.com/general/story/print/9622681/id=123

See the "print". This is the only additional directory in #2.

Basically I need a way by which I can apply a RegEx to original string
(i.e. #1) and should get the desired URL as in #2.

And if this can be done in one step that would be great as I need to
create a function which should do this conversion for all these kind of
URLs.

What is wrong with:

string newUrl = oldUrl.Replace("/story/", "/story/print/");

?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Regex help 1
Regex help needed 1
Regex help 8
Returning the ordinal position of regex matches in the originalstring 2
Regex Usage, or use Substring? 3
Need help in Regex. 9
Need help with Regex 1
Help in Regex 3

Top