Removing special character from a string

user1851420

I want to remove the special character @ from the following string

 $string="Test <a href='/group/profile/1'>@Test User</a> another test <a href='/group/profile/2'>@User Test</a>";

Expected output:

 <a href='/group/profile/1'>Test User</a> another test <a href='/group/profile/2'>User Test</a>"

Here i need to check each anchor tags in the string and need to find only the anchor tags with the word profile in href and need to remove the @ from the link text.If there is any @ outside the anchor tag in the string it should not be removed, only the @ in the anchor tag need to be removed.

colburton

Use a regular expression:

$string = preg_replace('/(<a href.*profile.*>)@/U', '$1', $string);

Mind the ungreedy (U) modifier.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Removing special Characters from string

From Dev

Removing special characters from a string

From Dev

Removing special Characters from string

From Dev

Removing special characters (¡) from a string

From Dev

Removing a character from a string efficiently

From Dev

Removing a character from a string in MASM

From Dev

Removing first character from string

From Dev

Removing a character from a string once

From Dev

Inserting and removing a character from a string

From Dev

Removing the last character from a string

From Dev

Remove � Special Character from String

From Dev

Convert string from special character

From Dev

Remove � Special Character from String

From Dev

Javascript substring character from string with special character '/'

From Dev

Removing special characters from query string in .htaccess

From Dev

Removing special characters from a string In a Groovy Script

From Dev

Removing all special characters from a string in Bash

From Dev

Windows Batch Function Removing Special Character From Arguments

From Dev

Windows Batch Function Removing Special Character From Arguments

From Dev

Removing sequence character from string JAVA

From Dev

removing a character from beginning or end of a string in Python

From Dev

Removing a null character from a string in javascript

From Dev

Removing backslash (escape character) from a string

From Dev

Removing words featured in character vector from string

From Dev

Removing lines from a string containing certain character

From Dev

Removing a character from a string in a list of lists

From Dev

Removing a character from a string in Python using strip()

From Dev

removing a character from beginning or end of a string in Python

From Dev

Removing first character from a string in octave

Related Related

  1. 1

    Removing special Characters from string

  2. 2

    Removing special characters from a string

  3. 3

    Removing special Characters from string

  4. 4

    Removing special characters (¡) from a string

  5. 5

    Removing a character from a string efficiently

  6. 6

    Removing a character from a string in MASM

  7. 7

    Removing first character from string

  8. 8

    Removing a character from a string once

  9. 9

    Inserting and removing a character from a string

  10. 10

    Removing the last character from a string

  11. 11

    Remove � Special Character from String

  12. 12

    Convert string from special character

  13. 13

    Remove � Special Character from String

  14. 14

    Javascript substring character from string with special character '/'

  15. 15

    Removing special characters from query string in .htaccess

  16. 16

    Removing special characters from a string In a Groovy Script

  17. 17

    Removing all special characters from a string in Bash

  18. 18

    Windows Batch Function Removing Special Character From Arguments

  19. 19

    Windows Batch Function Removing Special Character From Arguments

  20. 20

    Removing sequence character from string JAVA

  21. 21

    removing a character from beginning or end of a string in Python

  22. 22

    Removing a null character from a string in javascript

  23. 23

    Removing backslash (escape character) from a string

  24. 24

    Removing words featured in character vector from string

  25. 25

    Removing lines from a string containing certain character

  26. 26

    Removing a character from a string in a list of lists

  27. 27

    Removing a character from a string in Python using strip()

  28. 28

    removing a character from beginning or end of a string in Python

  29. 29

    Removing first character from a string in octave

HotTag

Archive