Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Removing all \n from a string

Expand Messages
  • Jeff 'japhy' Pinyan
    [Please do not top-post -- it makes the conversation difficult to follow] ... Yes: the meaning of treat string as multiple lines . The documentation for
    Message 1 of 18 , Jun 30, 2003
      [Please do not top-post -- it makes the conversation difficult to follow]

      On Jun 30, Stern, Leon said:

      >From: Jeff 'japhy' Pinyan [mailto:japhy@...]
      >>On Jun 30, Stern, Leon said:
      >>>$string =~ s/\n//gm
      >>What is the purpose of the /m modifier there? You don't have any ^ or $
      >>anchors in your regex, and those are the ONLY THINGS affected by using /m
      >>in a regex.
      > Modifier Meaning
      > g Match globally, i.e., find all occurrences.
      > i Do case-insensitive pattern matching.
      > m Treat string as multiple lines.
      > o Only compile pattern once.
      > s Treat string as single line.
      > x Use extended regular expressions.
      >Did I miss something?

      Yes: the meaning of "treat string as multiple lines". The documentation
      for pattern matching tells you specifically what is meant by "multiple
      lines" and "single line". It tells you exactly what /m and /s do. The
      thing is, the "multiple" and "single" mnemonics are poor at best; you
      wouldn't think you can use BOTH /m and /s on a regex, but you can.

      The long and short of it is this: /m changes how the ^ and $ anchors
      match, and THAT IS ALL; /s changes how . matches, and THAT IS ALL.

      Jeff "japhy" Pinyan japhy@... http://www.pobox.com/~japhy/
      RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
      <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
      [ I'm looking for programming work. If you like my work, let me know. ]
    Your message has been successfully submitted and would be delivered to recipients shortly.