Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28566

Re: regex tidy

From "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Newsgroups comp.lang.java.programmer
References <375vn9th0bc1faa04eg136be53hbvfjq4v@4ax.com> <bubj58Fn42U1@mid.individual.net> <8m54o913tjf1sagk75ktn7a0960nugpovv@4ax.com> <lltcuf$3mn$1@dont-email.me>
Subject Re: regex tidy
Date 2014-05-26 12:31 +0100
Message-ID <FfGdnX6yK_gaux7OnZ2dnUVZ8iGdnZ2d@bt.com> (permalink)

Show all headers | View raw


Joshua Cranmer ?? wrote:

> [Although this does raise the question of how regular expressions handle
> or fail to handle characters like ?? or the penguin in my display name.
> Stupid UTF-16 and the "it's fixed-width characters if you look at it
> funny" results.]

I don't know how the Java regexp implementation works (very badly, last time I 
looked, but that was /years/ ago) but you can easily handle variable-width 
characters by building the regexp over the underlying "words".

E.g. I (in another language) match UTF-8 patterns by transforming them into a 
FSA over the underlying byte sequences.  That increases the number of 
transitions needed to find a match to  be linear in the number of bytes of 
input rather than the number of characters, but means that my jump tables only 
have to handle 256 possible values instead of several million.

The test would be, does the trivial range "^["\uD8eD\uDC27"]$" (= 
^[<penguin>]$) match the input string "\uD8eD\uDC27" ("<penguin>"), or does it 
match either of the two input strings, "\uD8eD" or "\uDC27"?  (My UTF-16 
encodings may be wrong here, but you get the idea).

    -- chris 

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-23 11:39 -0700
  Re: regex tidy leif.roar@invalid.com (Leif Roar Moldskred) - 2014-05-23 14:33 -0500
    Re: regex tidy Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-05-23 15:05 -0500
  Re: regex tidy Robert Klemme <shortcutter@googlemail.com> - 2014-05-24 14:55 +0200
    Re: regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-25 09:09 -0700
      Re: regex tidy Robert Klemme <shortcutter@googlemail.com> - 2014-05-25 18:49 +0200
        Re: regex tidy leif.roar@invalid.com (Leif Roar Moldskred) - 2014-05-25 12:28 -0500
          Re: regex tidy Robert Klemme <shortcutter@googlemail.com> - 2014-05-25 19:55 +0200
          Re: regex tidy "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-05-26 12:12 +0100
    Re: regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-25 09:10 -0700
    Re: regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-25 09:13 -0700
    Re: regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-25 09:21 -0700
      Re: regex tidy Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-05-25 13:31 -0500
        Re: regex tidy "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-05-26 12:31 +0100

csiph-web