How to set property on regexp?

How to set property(such as multiline=true) of regexp object,there are no constractors to do this, thx!

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,886
    edited December 1969

    Can't you just use a new line character in the RegExp? What are you trying to do?

  • edited December 1969

    Sorry i'm not familiar with QtScript, but it seemed regexp not working with mutiline source,though I put "/m" at the end of partten,it just not working.

  • rbtwhizrbtwhiz Posts: 2,250
    edited December 1969

    Flags are passed in as a second [optional] argument to the RegExp constructor; or following the trailing slash in literal notation. The only valid characters are g, i and m. Where g = global match, i = ignore case, and m = multiline. When using the constructor, the flags are quoted. When using literal notation, the flags are not quoted.

    var regxAlphaGlobalInsensitive = new RegExp( "[A-Z]", "gi" );
    //var regxAlphaGlobalInsensitive = /[A-Z]/gi; //literal
    var sAlphaNumericMixed = "a1B2c3D4e5F6";
    print( sAlphaNumericMixed.replace( regxAlphaGlobalInsensitive, "" ) );//123456

    -Rob

  • edited December 1969

    I got it.Thx!

Sign In or Register to comment.