The regular expression described here is used in Substituting a Regular Expression for a Recordset Field.
Regular expressions are complex. There are many references available, on the Internet, and elsewhere, to help you understand them more fully.
(^|[^-.\d])(\d+(?:\.\d+)?)-(?=[^-.\d]|$)
A "capture group" is a regular expression surrounded by parentheses that is remembered as a numbered variable for use in the replacement.
Detail of Expression | Description |
---|---|
(^|[^-.\d]) A numbered capture group (Becomes $1 in the replacement) |
Select from 2 alternatives:
Beginning of line or string |
(\d+(?:\.\d+)?) A numbered capture group (Becomes $2 in the replacement) |
\d+(?:\.\d+)?
Any digit, one or more repetitions |
- |
(Match on trailing minus) |
([^-.\d]|$) Match a suffix but exclude it from the capture. |
Select from 2 alternatives:
Any character that is not in this class: |
This translates a string like "123.45-" to "-123.45".
© 1999-2007 Attachmate Corporation. All rights reserved. Terms of Use.