We help IT Professionals succeed at work.

Help with Match

greddin
greddin asked
on
Medium Priority
171 Views
Last Modified: 2012-06-27
I'm trying to match a string but I can't get it to match. I must be missing something.


String to match:

/ctb/groups/dotmil/documents/kjpage/~export/CTB_205589~1~KXPLAINSCRIPTTEMPLATE~SNIPPETLAYOUT/309554_2.gif

My Regular Expression:

^/.*/groups/(\\w*)/documents/(.*)/\\%7Eexport/(\\w*)\\%7E(\\d*)\\%7E(\\w*)\\%7E(\\w*)/(\\d*)_(\\d*)\\.(\\w*)$

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Have you tried using a literal ~ instead of the unicode value?
Not sure why you are escaping the \w and \d classes.  Are you defining this inside a Java string literal?

The following works fine in the regex tester, I use.

^/.*/groups/(\w*)/documents/(.*)/\~export/(\w*)\~(\d*)\~(\w*)\~(\w*)/(\d*)_(\d*)\.(\w*)$

Author

Commented:
Sorry for the delay in responding Mark. Thanks for the answer. Not sure why the \w and \d were escaped. This is code that I've inherited.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.