Module regex

String match and substitution with regular expression

Contents

Predicate


Top of this page Contents Index of this package LiLFeS Documents LiLFeS Home Page Tsujii laboratory

Predicate

regex_match/2

Formatregex_match(+REGEX, +TARGET)
Arguments
+REGEXstring regular expression
+TARGETstring target string
Success if regular expression REGEX matches the TARGET.
> ?- regex_match("i+", "lilfes").
 yes 

regex_match/3

Formatregex_match(+REGEX, +TARGET, -RESULT)
Arguments
+REGEXstring regular expression
+TARGETstring target string
-RESULTlist The first element is the whole matched string .The following elements is parts of matched expression(enclosed with parenthesis).
Get partial strings matched the regular expression.
> ?- regex_match("(hoge)(poge)", "hogepoge",X).
 X: < "hogepoge", "hoge", "poge" > 

regex_match/4

Formatregex_match(+REGEX, +OPTIONS, +TARGET, -RESULT)
Arguments
+REGEXstring regular expression
+OPTIONSlist list of options
+TARGETstring target string
-RESULTlist The first element is the whole matched string .The following elements is parts of matched expression(enclosed with parenthesis).
NoteThe folowing options can be used.
  • "ICASE" : Not case-sensitive
  • "i" : same as "ICASE"
  • "GLOBAL" : global matching (see example)
  • "g" : same as "GLOBAL"
  • "NEWLINE" : use character of linefeed as segmentation
  • "NOTBOL" : If appointed "NEWLINE","^" does not match linefeed.
  • "NOTEOL" : If appointed "NEWLINE","$" does not match linefeed.
Get partial strings matched the regular exoression.
> ?- regex_match("(a)+", ["i"], "aAbbaaa",X).
 X: < "aA", "a" >
 > ?- regex_match("(a)+", ["i", "g"], "aAbbaaa",X).
 X: < "aA", "aaa" > 

regex_subst/4

Formatregex_subst(+REGEX, +SUBST, +TARGET, -RESULT)
Arguments
+REGEXstring regular expression
+SUBSTstring 置き換える文字列
+TARGETstring target string
-RESULTstring 置換された文字列
Displace strings matched regular expression REGEX that is a part of TARGET with string SUBST.
> ?- regex_subst("hoge", "poe", "hoge-pe-n", X).
 X: poe-pe-n 

regex_subst/5

Formatregex_subst(+REGEX, +OPTIONS, +SUBST, +TARGET, -RESULT)
Arguments
+REGEXstring regular expression
+OPTIONSlist list of options
+SUBSTstring 置き換える文字列
+TARGETstring target string
-RESULTstring 置換された文字列
NoteThe folowing options can be used.
  • "ICASE" : Not case-sensitive
  • "i" : same as "ICASE"
  • "GLOBAL" : global matching (see example)
  • "g" : same as "GLOBAL"
  • "NEWLINE" : use character of linefeed as segmentation
  • "NOTBOL" : If appointed "NEWLINE","^" does not match linefeed.
  • "NOTEOL" : If appointed "NEWLINE","$" does not match linefeed.
Displace strings matched regular expression REGEX that is a part of TARGET with string SUBST.
> ?- regex_subst("l+", ["i"], "m", "LiLFeS", X).
 X: miLFeS
 > ?- regex_subst("l+", ["i", "g"], "m", "LiLFeS", X).
 X: mimFeS 

Top of this page Contents Index of this package LiLFeS Documents LiLFeS Home Page Tsujii laboratory

This document is automatically created by lildoc on Fri Sep 24 14:13:58 2004