Best syntax for bold
  • "Headings" - Page 2
  • Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

    Threaded View

    Re: Best syntax for bold
  • "Headings"
  • Jonathan N. Little wrote:

    Quoted text here. Click to load it

    Some regexp engines use $1, others use . My text editor uses the
    backslash syntax.

    Perl supports both, but treats them slightly differently. For example:

        print "Type a sentance> ";
        $_ = <>;        # Read a line.
        s/^(.+)\s+(.*)/$2 $1/;    # Swap around first 2 words.
        s/^(.+)\s+(.*)/ /;    # Swap them back.
        if (/^(.+)\s+/)        # If the sentance starts with a word
            { $first = $1; }    # Put it in $first.
        if (/^(.+)\s+/)        # Try this again...
            { $first = ; }    # Doesn't do what you expect!

    That is, $-style backreferences become available to the rest of your
    program until they get overwritten; \-style ones are only available
    within the original regular expression.

    PHP allows and $1 and also, in line with PHP's string interpolation
    synatx, and . They are all treated as equivalent, but the
    curly braces ones are useful for distinguishing between ambiguous
    cases. For example: '' versus '2; the former is backreference
    twelve followed by nothing; the latter is backreference one followed by
    the literal string '2'.

    sed uses to . The $-syntax is not recognised, and backreferences
    and higher are not supported.

    Toby A Inkster BSc (Hons) ARCS
    Contact Me  ~

    Site Timeline