OOP Posted September 20, 2010 Share Posted September 20, 2010 Hi there, I am trying to create a tool to do some auto-modifications to file content. I am not an expert in regular expression and I need to ignore white space when trying to match my content. For example, let say I have a file with the following code: <?php $i = 1; $j = 2; $x = $i + $j; echo $x; ?> Now I want to match the line $x = $i + $j; regardless of how many white space are between the variable $i,$j,and $x...is this possible? Quote Link to comment https://forums.phpfreaks.com/topic/213916-help-in-replacing-some-file-content-using-preg_replace/ Share on other sites More sharing options...
.josh Posted September 20, 2010 Share Posted September 20, 2010 '~$x\s+=\s+$i\s+\+\s+$j;~' the overall point is to use \s+ to signify one or more whitespace chars. Quote Link to comment https://forums.phpfreaks.com/topic/213916-help-in-replacing-some-file-content-using-preg_replace/#findComment-1113379 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.