programing

문자열에서 따옴표를 제거하려면 어떻게 해야 합니까?

minimums 2023. 9. 5. 20:04
반응형

문자열에서 따옴표를 제거하려면 어떻게 해야 합니까?

$string = "my text has \"double quotes\" and 'single quotes'";

모든 유형의 따옴표(다른 언어)를 제거하는 방법$string?

str_replace('"', "", $string);
str_replace("'", "", $string);

따옴표 말씀하시는 건가요?

그렇지 않은 경우 정규식으로 이동하면 HTML 인용문에 대해 다음과 같이 작동합니다.

preg_replace("/<!--.*?-->/", "", $string);

C-스타일 따옴표:

preg_replace("/\/\/.*?\n/", "\n", $string);

CSS 스타일 따옴표:

preg_replace("/\/*.*?\*\//", "", $string);

bash 스타일 따옴표:

preg-replace("/#.*?\n/", "\n", $string);

기타 등등...

동일한 작업을 한 줄에서 수행할 수 있습니다.

str_replace(['"',"'"], "", $text)

언급URL : https://stackoverflow.com/questions/4228282/how-do-i-remove-quotes-from-a-string

반응형