Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

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

g_state

nil turns off the magic of the meta-characters. Anything else turns on the magic interpretation.

Value Returned

t

The current setting.

nil

The given argument.

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

String Functions

rexCompile

rexSubstitute

rexReplace


Return to top
 ⠀
X