Guides/Regular Expressions/J Patterns

From J Wiki
Jump to navigation Jump to search
Overview | Verbs | Basic Patterns | J Patterns | Compiling Patterns

J Patterns

The following nouns defined in the jregex locale are patterns which match elements of J code:

name matches
Jname name
Jnumitem numeric item or array
Jnum numeric item or array
Jchar character string
Jconst numeric or character constant, including a. and a:
Jassign any assignment
Jgassign global assignment
Jlassign local assignment
Jlpar left parentheses
Jrpar right parentheses
Jsol start of a J sentence (ignores leading blanks)
Jeol end of a J sentence (ignores trailing blanks/comments)

Examples

   show=: showmatches_jregex_

   Jname show '10 myverb_myloc_ i.10'
10 myverb_myloc_ i.10
   ^^^^^^^^^^^^^ ^
   Jnumitem show '10 myverb 123e10, dat'
10 myverb 123e10, dat
^^        ^^^^^^
   Jnum show 'myverb 2 3 5 7'
myverb 2 3 5 7
      ^^^^^^^^
   Jcharitem show '10 myverb ''t'''
10 myverb 't'
          ^^^
   Jchar show '10 myverb ''testing'''
10 myverb 'testing'
          ^^^^^^^^^
   Jconst show '10 abc 2p1 def 1e5'
10 abc 2p1 def 1e5
^^^   ^^^^^   ^^^^
   Jassign show 'myverb abc=. def=: 123'
myverb abc=. def=: 123
          ^^    ^^
   Jlassign show 'myverb abc=. def=: 123'
myverb abc=. def=: 123
          ^^
   Jgassign show 'myverb abc=. def=: 123'
myverb abc=. def=: 123
                ^^
   Jlpar show 'myverb (,3);(i.5);''test'''
myverb (,3);(i.5);'test'
       ^    ^
   Jrpar show 'myverb (,3);(i.5);''test'''
myverb (,3);(i.5);'test'
          ^     ^
   Jsol show '    myverb 100  NB. test'
    myverb 100  NB. test
^^^^
   Jeol show '    myverb 100  NB. test'
    myverb 100  NB. test
              ^^^^^^^^^^