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.

有帮助吗?

解决方案

Try:

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

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top