joon1
February 21, 2019, 8:47pm
1
$myVar='ra123arf456rq578a9b';
$myVar1=preg_replace('/\d+/', '', $myVa
I have $myVar like the above.
The result of $myVar1 wil be “raarfrqab”
I like to remove all numbers which are just before “a”.
The follwoing is my target result.
raarf456rqa9b
Can I get my target result with your help?
rpkamp
February 21, 2019, 8:57pm
3
Well, you want to replace any digits directly before the character a .
So, we know digits have to be in the preg_replace and a has to be in there.
You already have digits (\d), but where is the a ? Where do you suppose it should go?
Actually, the result he wants is preg_replace("/\d+a/","a",$myVar);
1 Like
joon1
February 21, 2019, 11:43pm
7
Thank you it works fine.
By the way,
I think “reg” in preg means regular expresssion.
I like to know what “p” in preg means?
What does it stand for?
Perl.
PHP implements PCRE, or “Perl-Compatable Regular Expressions”. The function prefix for this group of functions is preg_
joon1
February 21, 2019, 11:51pm
9
Ah, Perl-Compatable Regular Expressions.
Thank you, m_hutely.
rpkamp
February 22, 2019, 7:47am
10
I know that, I just wanted to see if he could get there on his own.
Give a man a fish and all that
1 Like
That post… was in reference to a post that has since disappeared. lol.
1 Like
system
Closed
May 24, 2019, 5:33pm
12
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.