I am trying to update a config file from PHP using regexp. I cant seem to update digits.
This is my $contents:
$sugar_config['sysconfig_next_order_no'] = 'AAAAA';
$sugar_config['sysconfig_next_quote_no'] = '027827';
This is my $pattern:
/(.*sysconfig_next_order_no']\s=\s')(.*)(';)/
When I use all letters “AAAAAA” it works –
preg_replace($pattern, '$1AAAAAAA$3', $contents);
Result:
$sugar_config['sysconfig_next_order_no'] = 'AAAAAAA';
$sugar_config['sysconfig_next_quote_no'] = '027827';
When I use all numbers, it fails:
preg_replace($pattern, '$1123123$3', $contents);
Result:
23123';
$sugar_config['sysconfig_next_quote_no'] = '027827';
Can someone shed some light, I am forcing myself to always use regular expressions.
you have
next_order_noin your regex – so it is only going to match the text with that key. It is not about numbers or letters – that is the red herring!