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.
Asked
Active
Viewed 3,267 times
1
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 Answers
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