Regular expression.

 The format is following Regular expressions of Java.
 For details of the format,
 please refer to the specialized document of Regular expressions.

 Examples of regular expression format.

 abc    :to match specified string.
 ^abc    :to match specified string only top.
 .    :wild card, it show any character.
 a+    :previous character to match one or more.
 [abc]    :match any character in [].
 [^abc]    :negation, other. ^ is placed in the top.
 a-z    :match the character in the range-.
 a{n}    :n repetitions of the previous character.
 abc|def|ghi    select, any one of separated strings.
 (a)(b)    :grouping of string, (1st)(2nd) from left.
 \    :just after metachar > nomal char.
 \d    :to show any single digit.
 \w    :to show any single alphabet or digit.
 \n    :line feed code.
 \r    :carriage return.
 (?i)    :capital and small aren't distinguished, option.



  RE_PTN


  [Features]  To define the regular expression pattern.

  [Format]  RE_PTN "pattern-string"

  [Explanation]
    This pattern is used by 'RE_FIND', 'RE_REP', 'RE_REPALL'.
     It must be defined before 'RE_MAT'.

  [e.g.]
    10 re_ptn "a.c"
    20 re_mat "abc 123xx def 456zz "
    30 print re_find()
  (Result)
    -1



  RE_MAT


  [Features]  To specify the string for matching.

  [Format]  RE_MAT "Target-string"

  [Explanation]
    This string become a target of  'RE_FIND', 'RE_REGION', 'RE_REP', 'RE_REPALL'.
    And it is referenced in 'RE_GRP','RE_ST', 'RE_END'.

  [e.g.]
    10 re_ptn "abc|def"
    20 re_mat "abc 123xx def 456zz "
    30 print re_find()
  (Result)
    -1



  RE_REGION


  [Features]  To set range of the string to become the target.

  [Format]  RE_REGION start-pos, end-pos

  [Explanation]
    It affects the search-start-position of  'RE_FIND', 'RE_REP'.
    The first character is position 0. (It is the same as how to count Java)
    For example, when specify range of only one character of the 3rd character,
    It becomes  re_region 2,3
    The range will be reset in the setting of 'RE_MAT', from beginning to end.

  [e.g.] [smp_re1.bas]
    10 re_ptn "(\d+)(\w+)"
    20 re_mat "abc 123xx def 456zz "
    30 re_region  10,19
    40 print re_find()
    50 print re_grp$()
  (Result)
    -1
    456zz



  RE_FIND


  [Features]  To return existence(0,-1) by searching in a regular expression pattern from matching string.

  [Format]  RE_FIND

  [Explanation]
    Return value: existence=-1 not=0.
    The string/position found here is returned by 'RE_GRP' / 'RE_ST', 'RE_END'.
    The 2nd search, it will become the search from next position of last string.
    The position return to the top by 'RE_MAT' setting.

  [e.g.]
    10 re_ptn "def"
    20 re_mat "abc 123xx def 456zz "
    30 print re_find()
  (Result)
    -1



  RE_GRP$


  [Features]  To return the string as the group matched in 'RE_FIND'.

  [Format]  RE_GRP$([groupNo.])

  [Explanation]
    The group enclosed in parenthesis in the pattern
     has a number with No.1, No.2... from the left.
    It specify by group number what number position is acquired.
    When the 'groupNo.' is 0 or abbreviation,
     the string by the whole pattern is returned.

  [e.g.] [smp_re2.bas]
    10 re_ptn "(\d+)(\w+)"
    20 re_mat "abc 123xx def 456zz "
    30 print re_find()
    40 print re_grp$()
    50 print re_grp$(2)
  (Result)
    -1
    123xx
    xx



  RE_ST


  [Features]  The start position which matched by 'RE_FIND' is returned.

  [Format]  RE_ST()

  [Explanation]
    The first character is position 0. (It is the same as how to count Java)

  [e.g.]
    10 re_ptn "(\d+)(\w+)"
    20 re_mat "abc 123xx def 456zz "
    30 print re_find()
    40 print re_grp$()
    50 print re_st()
  (Result)
    -1
    123xx
    4



  RE_END


  [Features]  The end position which matched by 'RE_FIND' is returned.

  [Format]  RE_END()

  [Explanation]
    The end of the first character is position 1. (It is the same as how to count Java)

  [e.g.]
    10 re_ptn "(\d+)(\w+)"
    20 re_mat "abc 123xx def 456zz "
    30 print re_find()
    40 print re_grp$()
    50 print re_end()
  (Result)
    -1
    123xx
    9



  RE_REP$


  [Features]  In the matching string, the part which corresponds to the pattern first, is replaced by replacement letter and return.

  [Format]  RE_REP$("replacement-string")

  [Explanation]
    The replacement starting position can be specified by 'RE_REGION'.

  [e.g.]
    10 re_ptn "cm"
    20 re_mat "abc 123cm def 456cm "
    30 print re_rep$("km")
  (Result)
    abc 123km def 456cm


  RE_REPALL$


  [Features]  In the matching string, all the parts corresponding to the pattern, are replaced by replacement letter and return.

  [Format]  RE_REPALL$("replacement-string")

  [Explanation]
    It is used for replacement of the string.

  [e.g.] [smp_re3.bas]
    10 re_ptn "cm"
    20 re_mat "abc 123cm def 456cm "
    30 r$=re_repall$("km")
    40 print r$
  (Result)
    abc 123km def 456km