Russ Johnson wrote:
Jim Beard wrote:

I know this isn't exactly the list for it, but I've been reading online for a while now and can't make heads or tails of my problem. I want to match convert '&lt;' sequences to '<' using a replace method that matches on a regex pattern. I'm using Java and am having 0 luck. No sites online seem to mention & or ; other then in passing as a punctuation character...

Shouldn't this be easy?

Yes, and I found a perl example with the search here: http://www.google.com/search?q=perl+replace+%22%26lt%3B%22+%3C&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official

That reveals a bunch of pages. Among them, (http://www.codepedia.com/1/PerlPMTutorial).

Down the page is this:

$input =~ s/>/&gt;/g;

Which tells perl to take the value of $input, find occurrences of ">" and replace that with "&gt;", globally. Then stick the results back into $input.

If you replace the > and &gt; with your values, it should be pretty simple to get the rest of it as well.

Jim wants to do the opposite conversion.  Regular expressions
don't simply reverse.  In other words
s/a/./g  has a very different behavior than  s/./a/g
--
Allen Brown  [EMAIL PROTECTED]  http://www.peak.org/~abrown/
  Real programmers use C because it is the easiest to spell.
_______________________________________________
EUGLUG mailing list
euglug@euglug.org
http://www.euglug.org/mailman/listinfo/euglug

Reply via email to