rockinghorse Posted September 30, 2011 Share Posted September 30, 2011 Have been tearing my hair out about this one (and I don't have a lot of hair!): how do I preg_replace postCode="xxx" with postCode="yyy"? I have tried preg_replace('postCode=".*"','postCode="yyy"',$input) and many variations but I just can't seem to get it to work. Any help appreciated. NB, that postCode is within other text, so: blah="moo" foo="bar" postCode="yyy" ... Link to comment https://forums.phpfreaks.com/topic/248182-preg_replace-postcode/ Share on other sites More sharing options...
JAY6390 Posted September 30, 2011 Share Posted September 30, 2011 preg_replace('~postCode="[^"]*"~', 'postCode="yyy"', $input) Link to comment https://forums.phpfreaks.com/topic/248182-preg_replace-postcode/#findComment-1274410 Share on other sites More sharing options...
rockinghorse Posted September 30, 2011 Author Share Posted September 30, 2011 Thank-you very much! That sorted it. Link to comment https://forums.phpfreaks.com/topic/248182-preg_replace-postcode/#findComment-1274412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.