Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace Between X and Y

Status
Not open for further replies.

ScottCybak

Programmer
Sep 29, 2000
48
CA
I've read str_replace, ereg_replace and preg_replace, but still can't formulate what the heck i need to do..

I'm trying to extract the string between <x> and <y> from a string. So, say the string is

&quot;<x>This will be visible</y> This won't <x>This will be as well</x>&quot;

i want it to return:

<x>This will be visible<y><x>This will be as well</x>

ultimately, it will convert the x and y to a <p> </p> tag, but that is the least of my worries.

I was just about to code a big character scan loop but thought perhaps i just don't understand the function that i need to use.

TIA! Scott Cybak
Nighthawk Transport Inc.
 
try looking at trim() ***************************************
Party on, dudes!
[cannon]
 
you have to use regular expressions.

you have to be something like this:

the pattern you need is something like this:
&quot;<x>([a-zA-Z ]+)<[y|/x]>&quot;


Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top