Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting RegEx Match  RSS feed

 
Mike London
Ranch Hand
Posts: 1332
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the Mac Utility RegExRx, I can match several mult-lines in an XML file using this RegEx: "<key>Watch.*</key>.*</string>"

This RegEx correctly shows 14 matches.

An example of the multiline text found is:




---

Yet, the same code in Java fails.

I've tied using the Pattern.MILTILINE, as shown below, and the Pattern.DOTALL but I get no match.



Any ideas how to make this work?

Would appreciate any suggestions.

Thanks,

-- mike
 
Henry Wong
author
Sheriff
Posts: 22818
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Are you missing the first match? If so, then it is your code. You do an "if" statement, and then, a "while" statement -- so, the results from find() from the "if" statement is discarded, as the find() in the "while" statement goes after the next match.

Henry
 
Mike London
Ranch Hand
Posts: 1332
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Are you missing the first match? If so, then it is your code. You do an "if" statement, and then, a "while" statement -- so, the results from find() from the "if" statement is discarded, as the find() in the "while" statement goes after the next match.

Henry


Thanks for your reply.

Upon further examination, the actual problem seems to be that the plist format in Mac OS, current versions, is binary. There's a built-in Mac utility to convert the plist from binary to text (ptutil).

Update: When I ran the command previously, I didn't include the correct path. Since the ptutil just gave me my prompt back, I didn't realize it hadn't found the file.

All good now!

Thanks again for your help.

-- mike
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!