Regular Expressions in J 
Author Message
 Regular Expressions in J

Roger Hui writes on January, 15:

Quote:
>Regular expressions can be introduced in any number of ways without
>making obsolete current uses of E. . However, E. may not be the
>best place for regular expressions because a boolean
>result may be too poor a medium to represent the information
>or to achieve desired effects. in any case, the following are
>some possibilities:

>        'b*c'    E.!.1 'boustrophedonic back and forth'
>   1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

What about ...
        'b*c'    E.!._1 'boustrophedonic back and forth'
   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0
And how about context sensitivity , e.g. distinguishing between strings appearing
at the beginning, in the middle and at the end of a line.
This might suggest something like E.!.110 could mean 'dont want the string at the end'
It might be nice to permit line delimiters rather than force E. to operate only
on atomic lines; in which case 22!:1 (13{a.) could use CR as the delimter, say.

Quote:
>        'b*c'    <;.4  'boustrophedonic back and forth'
>      +---------------+-+---+-----------+
>      |boustrophedonic| |bac|k and forth|
>      +---------------+-+---+-----------+How about

    'b*c'    (FOO=.<);._4  'boustrophedonic back and forth'
     +------------------+-----+-----+--------------+  
     |+---------------++|++-+|+---++|++-----------+|
     ||boustrophedonic||||| |||bac|||||k and forth||
     |+---------------++|++-+|+---++|++-----------+|
     +------------------+-----+-----+--------------+
This way we would know whether the argument to FOO was a string that was a regular
expression, or not

Or alternatively:


Which would produce a similar result, but allows the user to specify an action if the
string is found or not.
      +-------------------+-----+-------+---------------+
      |FOO=boustrophedonic|GOO= |FOO=bac|GOO=k and forth|
      +-------------------+-----+-------+---------------+

which could do the job of

Quote:
>  ('b*c';'hit') 22!:2 'boustrophedonic back and forth'e.g.      'b*c' (('hit'&[)`(]));._4 'boustrophedonic back and forth'

Further considerations:
How would regular expressions be defined?
Would a more fruitful approach be to introduce 22!:0 as an entry point into a complete
lexical analyser such as lex.

David Alis



Mon, 12 Jul 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. JS-EAI with *JS*-callback

2. js.exception 3279.js

3. regular expression matching in J ? (or APL)

4. Tgen, linear algebra, and regular expression package available

5. Regular Expressions

6. Regular Expression Matcher v1.1

7. apl and regular expressions

8. php like regular expressions in apl?

9. Support for regular expressions in APL?

10. Benchmarking Regular Expressions in J3.05

11. regular expression discussion

12. Regular Expression to match HTML elements

 

 
Powered by phpBB® Forum Software