1

I have string Adult-Cruise+Lunch_label i want to remove + sign from the string. I have used preg_replace('/\s+/', '', $_option->getTitle()) to remove space from the string. how can i add code to remove + sign from the string.

Zaheerabbas
  • 1,119
  • 20
  • 46
  • This sounds like an XY problem. What's the bigger picture? What's `$_option`? and what's `getTitle()`? Will there be any other characters that might appear in this string that you want removed? – Dave Chen Apr 04 '14 at 05:08

3 Answers3

4

Try:

preg_replace('/[\s\+]/', '', $_option->getTitle());
vee
  • 38,255
  • 7
  • 74
  • 78
2

You could use:

preg_replace(/[+]/, "", $_option->getTitle());

This will remove only the plus sign from the string.

Marti Markov
  • 746
  • 6
  • 25
0

You canu remove + sign using javascript replace function.

var string = "Adult-Cruise+Lunch_label"; string = string.replace('+','%2B');

I think it may be work.

Shailesh Katarmal
  • 2,757
  • 1
  • 12
  • 15