Regex Basics

View some of the Frequently Asked Questions to our support staff. Included are some tips and tricks making this forum ideal for users getting started with GoAnywhere MFT. Note: Users can reply to existing topics but only our support staff can add new topics to this forum.
1 post Page 1 of 1

Support_Hans

Support Specialist
Posts: 6
Joined: Mon Jul 22, 2019 11:32 am

Post by Support_Hans » Fri Aug 02, 2019 2:16 pm
A regular expression, commonly referred to as a "regex", is a pattern that can be used to search for and replace sets of characters in a given string of files. GoAnywhere supports the regex patterns available to the java.util.regex class.

Example: Given the string "abc.txt", a search pattern such as "(.*)\.txt" can be used to look for any string that matches this regex. This search pattern broken down is as follows:

- "(.*)" refers to any group of characters, with a group size 0 or greater.
- "\." is quoting the '.' character. '.' itself can refer to any character, as shown in the step above
- "txt" is that string itself

To summarize, the search pattern is looking for any file with the suffix ".txt".

A replace pattern "$1.csv" can be used to change the given string. This regex broken down is as follows:

-"$1" refers to the first captured group of the search pattern. In this case, the first captured group is "(.*)", or "abc" from the given string.
-".csv" will be changing the file suffix from ".txt".

To summarize, the replace pattern will be keeping the file name, but changing the file suffix to ".csv". The new string will be "abc.csv".

More information can be found in the Oracle Java Documentation. Oracle also provides Regular Expression tutorials that explain each construct with examples. Both of those links can be found below:

https://docs.oracle.com/javase/7/docs/a ... ttern.html
https://docs.oracle.com/javase/tutorial ... index.html

The User Guide of GoAnywhere MFT also provides a summary of regex constructs under the navigation "Appendix" > "Wildcards and Regular Expressions".
1 post Page 1 of 1