Jump to content

Selecting Content in Between


atlanta

Recommended Posts

Hey i needed a little help with selecting the stuff in between this code

 

table table table {

border-style:solid;

border-width:1px;

border-color:A47040;

background-color:EEE3CF; 

 

So i would want the regex function to return

border-style:solid;

border-width:1px;

border-color:A47040;

background-color:EEE3CF;

 

could someone help me out with writting the expression correctly thanks

Link to comment
https://forums.phpfreaks.com/topic/101466-selecting-content-in-between/
Share on other sites

  • 2 months later...

Can this be done without a trim?  Or do you always need to trim when you want to match items in between delimiters?

 

ie. I have this:

 

<highlight>text</highlight>

 

And I only want to display

text

 

Would I need to trim off

<highlight>

 

Or can this be done through regex?

trim() is not required, we use it just to remove spaces from the beginning and end of a string. Example: if you have this string:

 

<highlight>  some text here     </highlight>

 

we can remove <highlight> and </highlight> using this code:

 

$str = preg_replace("/<\/?highlight>/", "", $str);

 

which will result in

 

$str = "  some text here     ";

 

and use trim (optional) to remove the spaces.

 

$str = trim($str)
/* $str = "some text here"; */

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.