Remove substring like this+immediate next character in php

Tush
$srt=HDD(2GB*2)qty3##HDD(4GB*2)qty4##HDD(2GB*2)qty5

In above example i need to replace qty+next numeric value with null

RomanPerekhrest

The simplest way for such case is using preg_replace function:

$srt= "HDD(2GB*2)qty3##HDD(4GB*2)qty4##HDD(2GB*2)qty5";
$srt = preg_replace("/qty\d+?/", "", $srt);

print_r($srt);  // "HDD(2GB*2)##HDD(4GB*2)##HDD(2GB*2)"

For additional condition: 'replace qty3## like all with " ,"'

...
$srt = preg_replace("/qty\d+?##/", " ,", $srt);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get the next immediate numeric substring in a php string

From Dev

How to remove Unicode like English character in PHP?

From Dev

How to replace a specific character in a string along with the immediate next character

From Dev

perl remove substring before a character

From Dev

In PHP substring return �� these type of character?

From Dev

In PHP substring return �� these type of character?

From Dev

How to remove all occurrences of a character/substring?

From Dev

Remove a substring from a string starting from a character

From Dev

Is substring or replace faster to remove the last character in a string?

From Dev

Remove the next letter after a specific character?

From Dev

Remove next character jQuery (no html elements given)

From Dev

How to substring within the special character using PHP?

From Dev

Oracle/ PLSQL- Substring Till Next Occurence of Character

From Java

In R remove all characters in string that is substring of other character

From Dev

C# Regex to match any character next to a specified substring but ignoring newline/tab character

From Dev

Remove newline in text file, when there is a character on the beginning of the next line

From Dev

How to get substring of string using starting and ending character in PHP?

From Dev

How to remove the unwanted character like white spaces and newline from a string

From Dev

Remove everything up to and including character in PHP string

From Dev

Remove the last character using strrchr and substr in PHP

From Dev

PHP/Smarty Remove Everything after character

From Dev

regex, remove all but one character in PHP

From Dev

PHP/JSON - Remove every occurence of certain character before another character

From Dev

PHP preg_replace remove text from substring and end tag?

From Dev

php regular expressions for substring start with A, end with B in order to remove the A and B

From Dev

Aligning virtual address to immediate next page boundary

From Dev

SQL Microsoft Access Show immediate next row

From Dev

find the very next instance of a character string using php

From Dev

Swift: Substring based on a character

Related Related

  1. 1

    Get the next immediate numeric substring in a php string

  2. 2

    How to remove Unicode like English character in PHP?

  3. 3

    How to replace a specific character in a string along with the immediate next character

  4. 4

    perl remove substring before a character

  5. 5

    In PHP substring return �� these type of character?

  6. 6

    In PHP substring return �� these type of character?

  7. 7

    How to remove all occurrences of a character/substring?

  8. 8

    Remove a substring from a string starting from a character

  9. 9

    Is substring or replace faster to remove the last character in a string?

  10. 10

    Remove the next letter after a specific character?

  11. 11

    Remove next character jQuery (no html elements given)

  12. 12

    How to substring within the special character using PHP?

  13. 13

    Oracle/ PLSQL- Substring Till Next Occurence of Character

  14. 14

    In R remove all characters in string that is substring of other character

  15. 15

    C# Regex to match any character next to a specified substring but ignoring newline/tab character

  16. 16

    Remove newline in text file, when there is a character on the beginning of the next line

  17. 17

    How to get substring of string using starting and ending character in PHP?

  18. 18

    How to remove the unwanted character like white spaces and newline from a string

  19. 19

    Remove everything up to and including character in PHP string

  20. 20

    Remove the last character using strrchr and substr in PHP

  21. 21

    PHP/Smarty Remove Everything after character

  22. 22

    regex, remove all but one character in PHP

  23. 23

    PHP/JSON - Remove every occurence of certain character before another character

  24. 24

    PHP preg_replace remove text from substring and end tag?

  25. 25

    php regular expressions for substring start with A, end with B in order to remove the A and B

  26. 26

    Aligning virtual address to immediate next page boundary

  27. 27

    SQL Microsoft Access Show immediate next row

  28. 28

    find the very next instance of a character string using php

  29. 29

    Swift: Substring based on a character

HotTag

Archive