rexMagic
rexMagic( [g_state] ) =>t/nil
Description
Turns on or off the special interpretation associated with the meta-characters in regular expressions.
By default the meta-characters (^, $, *, +, \, [, ], etc.) in a regular expression are interpreted specially. However, this “magic” can be explicitly turned off and on programmatically by this function. If no argument is given, the current setting is returned. Users of vi will recognize this as equivalent to the set magic/set nomagic commands.
Arguments
|
|
Value Returned
Examples
rexCompile( "^[0-9]+" )
=> t
rexExecute( "123abc" )
=> t
rexSubstitute( "got: \\0")
=> "got: 123"
rexMagic( nil )
=> nil
rexCompile( "^[0-9]+" )
=> t recompile w/o magic
rexExecute( "123abc" )
=> nil
rexExecute( "**^[0-9]+!**")
=> t
rexSubstitute( "got: \\0")
=> "got: \\0"
rexMagic( t )
=> t
rexSubstitute( "got: \\0")
=> "got: ^[0-9]+"
rexMagic(nil) ;; switch off
rexSubstitute("[&]")
=> "[&]"
Related Topics
Return to top