Michael_ Posted April 6, 2010 Posted April 6, 2010 I need help understanding the backreference flavor used in this regex plugin: //regexReplaceAll( text; regex; replacement) For example, what would the replacement backreference be for string1 in the following regex pattern: "(string1)(string2)" I'm trying all sorts of backslashes, numbers, ampersands, and dollar signs in combination and with curly parenthesis, and cant seem to get it.
Smef Posted April 8, 2010 Posted April 8, 2010 You may want to look up a guide for RegEx on google. http://www.regular-expressions.info/
Michael_ Posted April 8, 2010 Author Posted April 8, 2010 David, as a paying customer directed here by your company's website for support, I think your answer could have been a little more helpful than suggesting I google for a regex tutorial. I have a basic familiarity with regular expressions in environments beyond your product. I am trying to adapt that knowledge to the particularities of your product. Unlike other providers of paid plugins, 360Works provides minimalist documentation, at least for the regular expressions product. Here is the totality of 360Works documentation on backreference replacement in a regular expression: Quote Replacement - The text to replace the found occurrences with. This may contain *backreferences*. Unquote The word *backreference* then points to an external url containing the following information: Quote This syntax differs greatly between various tools and languages, far more than the regex syntax does. Please check the replacement text reference for details.... The list of replacement text flavors is not the same as the list of regular expression flavors... The reason is that the replacements are not made by the regular expression engine, but by the tool or programming library providing the search-and-replace capability. Unquote This external reference to the googlespace, provided by 360Works, then goes on to reference no fewer than 15 *flavors* of backreference usage that vary by tool. Since customers of 360Works have no way of knowing, based on information provided by 360Works with the commercial product, what tool they utilize, we are at this point, up the creek, with no recourse except to ask for a thoughtful, straight answer from a representative of the vendor. So, I try again, and will provide some multiple choice examples to get the thought process going. Would the backreference for (string1) in the parenthetically split regular expression (string1)(string2) be something like 1 or more like $1 or perhaps ${1} or maybe $1 or even &1 or something exquisitely different than any of the above? I bet we're talking less than 10 keystrokes here. I remain, Your Humble Customer
Smef Posted April 12, 2010 Posted April 12, 2010 I'm sorry that I couldn't be more helpful for you. I really don't know regex at all, and the person who made the plugin and DOES know regex has been out of the office. I've emailed the person who knows regex and hopefully he will be able to help you when he gets back in.
shmert Posted April 12, 2010 Posted April 12, 2010 Hello, thanks for pointing out the flaw in the documentation, that will be fixed in the next release. The backreferences use a $1, $2, $3, etc. syntax. The number indicates which group to use. A group is a part of the pattern enclosed in parentheses. It looks like you've already tried this, can you post the entire function call here? As well as the text being operated on. Thanks!
Recommended Posts
This topic is 5338 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now