I suck at writing regual expressions so if some one call help that would great.
String looks like.
background: rgb(156, 123, 173)
url(/images/interface/side_bar_02.gif) repeat-x scroll 0%; font-family:
verdana,arial,sans-serif; color: rgb(156, 123, 173); line-height:
1.5em; -moz-background-clip: initial; -moz-background-origin: initial;
-moz-background-inline-policy: initial; font-size: 0.8em;
I need to find font-size: 0.8em;
so I would like to do a search for 'font-size:' and the 'em;' part regardless what the number in the middle is set too.
this is client side as it is manipulting the css stylesheet.
Cheers
phpScott
[solved] find within a string
Moderator: General Moderators
[solved] find within a string
Last edited by phpScott on Thu May 05, 2005 7:55 am, edited 1 time in total.
you could do something like this :
of course this assumes that your font will be the 7th semi-colon delimited entry in the string every time. you coudl also do a array search to find the font-size pattern, but this should be enough to get you started 
hope this helps...
Code: Select all
$str = explode(',','
background: rgb(156, 123, 173)
url(/images/interface/side_bar_02.gif) repeat-x scroll 0%; font-family:
verdana,arial,sans-serif; color: rgb(156, 123, 173); line-height:
1.5em; -moz-background-clip: initial; -moz-background-origin: initial;
-moz-background-inline-policy: initial; font-size: 0.8em;');
for($i=0; $i<count($str); $i++)
{
if($i==7)
{
echo $str[$i];
}
}hope this helps...
solved while waiting for replies?
I know that replace should be using a regular expression but it seems to work.
Cheers though.
phpScott
Code: Select all
find = "e;font-size: "e; + currentSize + "e;em;"e;;
newSize = "e;font-size: "e; + size + "e;em;"e;;
testing = bodyRule.replace(find, newSize);Cheers though.
phpScott
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia