Question

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.

Was it helpful?

Solution

Try:

preg_replace('/[\s\+]/', '', $_option->getTitle());

OTHER TIPS

You could use:

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

This will remove only the plus sign from the string.

You canu remove + sign using javascript replace function.

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

I think it may be work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top