1

I am using a proprietary CMS and it has a URL rewrite tool that I am trying to use Regex to return the URL in all lowercase.

The format of the Tool is Pattern (Where you put in what is entered by and end user) and Substitution (where you put in what you would like it changed to.

I've been trying to use Pattern : www.domain.com/.*$1[A-Z] Substitution: www.domain/com/$[a-z]

However that is not picking anything up. I've never used Regex before and need ome help.

John Paul
  • 44
  • 4

1 Answers1

1

It's different for different flavors of regex, but you should try something like:

pattern:      www.domain.com/(.*)
substitution: www.domain.com/\L$1

Generally in a substitution string, the case flags you should watch for are:

  • \L lowercase all proceeding letters
  • \U uppercase all proceeding letters
  • \l lowercase the next letter
  • \u uppercase the next letter
  • \E stop case conversion (e.g. all following letters are as-matched)
Adam Smith
  • 52,157
  • 12
  • 73
  • 112
  • The regex is in Java. I tried that, but I'm getting a Error: String index out of range: 30 error. – John Paul Mar 19 '15 at 20:53
  • @JohnPaul related, then, is [this question](http://stackoverflow.com/questions/2770967/use-java-and-regex-to-convert-casing-in-a-string) whose answer states: "You can't do this in Java regex." There are other ways to handle that in Java, but if you're restricted to using regex to solve this in Java, it's not possible. – Adam Smith Mar 19 '15 at 20:55