Here’s i have an issue : sentence : “12223233 sekamar berempat” result: sekamarberempat expectation: sekamar berempat thank you Answer You can replace all chars other than lowercase letters with a space and trim the string: See the PHP demo.
Tag: preg-replace
Using preg_replace to reformat money amounts in text with PHP
I’m struggling with some regular expressions. What I want to do is find money amounts in a string, remove the €,$, or £ but keep the number, and then look to see if there is a ‘b’ or an ‘m’ – in which …
Is there any way to add a starting of link to a unknown m3u8 file
I recently wrote a code which uses file_get_contents along with some USER_AGENT headers and other headers to get a source of a m3u8 file , when echoed it looks like following #EXTM3U #EXT-X-STREAM-INF:…
How do I find and remove body selectors in CSS
I am working on my PHP to find the body selectors under the style tags. I want to search for each body selector in the style tags to remove them to prevent them changing the body in my html especially …
PHP preg_replace: Replace All Hyphens in String That Appear Before the Last Hyphen w/ Space
Using preg_replace (or other PHP-based option): I need to replace all hyphens in a string, that appear before the last hyphen, with space. Example #1 of the Result I Need: string = My-Cool-String – …
regex preg_replace php
I have random variable like: Strip @ 489.000 Strip 1 @ 489.000 Strip 2 @ 589.000 I need output will be: only number after ‘anything @ ‘ 489.000 so give me output: 489.000 489.000 589.000 hot to …
When do I need u-modifier in PHP regex?
I know, that PHP PCRE functions treat strings as byte sequences, so many sites suggest to use /u modifier for handling input and regex as UTF-8. But, do I really need this always? My tests show, that this flag makes no difference, when I don’t use escape sequences or dot or something like this. For example preg_match(‘/^[da-f]{40}$/’, $string); to check
how to change an url before to use on php
I have a function of a download parser, where the url of one site it’s changed: http://paste.co to https://controlc.com/ I can’t change the url from a database, because aare encrypted. class …
Remove pieces of string
Ok, ive imported contents of .txt file into array, and im having problems with removing some parts of the string in array. This is the sample output of the array: [55] => …
Replace pairs of symbols in chat text with html tags to style as bold, italic, and strikethrough
I am trying to make a whatsapp style text post. When user create text like this: then this text is automatically changing like this Hi how are you where are you I know i can do it with php regex like this: The example is for bold text: But there is a problem it should be remove * when text