RegSubs - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


StringTools

  

RegSubs

  

perform regular expression substitutions

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

RegSubs( env, text )

Parameters

env

-

string = string; substitution to make

text

-

string; text to substitute into

Description

• 

The RegSubs(env,text) command replaces each occurrence of a substring matching the left-hand side of env with the right-hand side of env in the string text.

  

If no substring of text matches the left-hand side of env, then text is returned unchanged.

• 

This procedure is closely related to StringTools[RegSub], but provides a more intuitive interface. The chief difference between the two is that RegSubs effects all relevant substitutions (serially), while StringTools[RegSub] performs a single substitution. Also, the left-hand side of env cannot match an empty substring of text. (An exception is raised in this case.)

• 

All of the StringTools package commands treat strings as (null-terminated) sequences of 8-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

withStringTools:

RegSubs((a))=gu\\1v\\2,abc

guavabc

(1)

RegSubs([abc]*)d=&-\\1,abbbcd

abbbcd-abbbc

(2)

RegSubsa([bc]*)(c*d)=&-\\1-\\2,abcd

abcd-bc-d

(3)

RegSubs(bc+d$|ef*g.|h?i(j+k))=&-\\1-\\2,effgz

effgz-effgz-

(4)

RegSubs(bc+d$|ef*g.|h?i(j|k))=&-\\1-\\2,reffgz

reffgz-effgz-

(5)

RegSubs(.*)c(anad[ai])(.*)=\\1C\\2\\3,Maple is canadian

Maple is Canadian

(6)

RegSubs[ \t]+= ,Some text \t\t with extra \t space.

Some text with extra space.

(7)

See Also

Regular_Expressions

string

StringTools

StringTools[RegMatch]

StringTools[RegSub]

StringTools[Substitute]

StringTools[SubstituteAll]