I need to match fixed number of zeroes (which are strings), followed by a new line, and delete it from string.
This is the pattern I'm working on:
000000000000000
000000000000000
000000000000000
000100000001000
000010000010000
000001000100000
001000111000100
000100010001000
000010010010000
000001010100000
001000111000100
000100010001000
000010010010000
000001010100000
000000111000000
001111111111100
000000010000000
000000010000000
000000010000000
000000010000000
000000010000000
000000010000000
000000010000000
000000000000000
000000000000000
The PHP code is:
$regex = '/^[0{' . $amount . '}]\n$/m'; // /^[0{15}]\n$/m
$pattern = preg_replace($regex, null, $pattern); // $pattern is pattern above
You don’t need the $
there in regexp (because after \n
there are digits again.). The square brackets are used for “one of,” you don’t need them here. I doubt also whether you need a “at the very first position” marker ^
. And replacer should be a string:
$regex = '/0{' . $amount . '}\n/m'; // /^[0{15}]\n/m
$pattern = preg_replace($regex, '', $pattern); // $pattern is pattern above
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다