Categories

ep.escapeExpStr()

Categories: Utilities

ep.escapeExpStr( string, [ except ] )

Plugin: ep.core

Description: Escape an string for use as regular expression.

  • ep.escapeExpStr( string, [ except ] )

    version added: 6.11.0

    string   A string to escape.

    except   A string containing characters to except from escaping.

The ep.escapeExpStr() method escape reserved regular expression characters.

  • Escape all reserved regular expression characters.

    Code:
    var string = '[A-Z]*[()0-9]+';
    
    ep.escapeExpStr( string );
    
    Results:
    \[A-Z\]\*\[\(\)0-9\]\+
    
    
  • Escape reserved regular expression characters, excepting []*+.

    Code:
    var string = '[A-Z]*[()0-9]+';
    
    ep.escapeExpStr( string, '[]*+' );
    
    Results:
    [A-Z]*[\(\)0-9]+