Regex Differences between Java and Ruby

java, regex, ruby

Solution

Here is a good place to start:

- specifics for Java (mostly usage of regex in general)

- specifics for Ruby (mostly usage of regex in general)

- flavor comparison (mostly regex syntax and features)

Mostly note that in Ruby your write regexes by delimiting them with `/`, and in Java you need to double-escape everything (`\\` instead of `\`) so that the backslashes get through to the regex engine. Everything else you should find within those links I gave you above.

For the sake of completeness of this answer, I would also like to include Tom's Link to this online regex tester, that supports a multitude of regex flavors.

You should go ahead and give both regexes a go. If you encounter any problems, you are more than welcome to ask a new (specific) question, showing your own attempts.

Problem

I'm trying to write a regex for: - Strings of characters beginning and ending with a double quote character, that do not contain control characters, and for which the backslash is used to escape the next character. - The paren-star form of comments in Pascal: strings beginning with `(*` and ending with `*)` that do not contain `*)` I'm trying to write a version in Ruby, then another in Java, but I'm having trouble finding the differences in regex expressions for both. Any help is appreciated!

Original source