카테고리 없음

[perl] Perl에서 "\"를 "//"로 어떻게 바꾸나요?

행복을전해요 2021. 1. 6. 13:37
s[\\][//]g
  • \ needs to be escaped in a regex
  • / does not
  • Avoid using / to delimit regex sections when using / in the expression itself (it makes things much more readable!)

... but you should probably use something like Path::Class.

-------------------

우선, 다른 구분 기호를 사용하면 \정규식을 더 쉽게 읽을 수 있습니다.

그런 다음를 교체해야 \와 함께 \\, 또는 다음과 같은 문자 (A 탈출하는 데 사용되는 /정규식에 사용된다).

$link =~ s|\\|//|g;
-------------------

나는 이것이 그것을해야한다고 생각한다 :`

$str =~ s{\\}{//}g; 


출처
https://stackoverflow.com/questions/2005832