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


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

Re: check if string has non-word characters

From Marcel Mueller <news.5.maazl@spamgourmet.org>
Newsgroups comp.lang.java.programmer
Subject Re: check if string has non-word characters
Date 2015-06-16 18:42 +0200
Organization MB-NET.NET for Open-News-Network e.V.
Message-ID <mlpjm5$r0d$1@gwaiyur.mb-net.net> (permalink)
References <471b79ac-8ba1-40d4-8630-e75a8ca20abe@googlegroups.com>

Show all headers | View raw


On 16.06.15 16.20, mike wrote:
> String is not allowed to contain non-word characters. However it is ok with:
>
> 1.  = in as long it is not in the end or beginning of string.
> 2.  , as long as it is at the end of the string.

Sounds like a key value parser for configuration strings. But I am 
puzzled about the comma at the end.

"^(\\w+)(?:=(\\w+))?,?$"

$1 receives the key, $2 the optional value. The comma is discarded.

However, if you intended to allow /multiple/ = signs then

"^\\w(?:[=\\w]*\\w)?,?$"

should check for that.


Marcel

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


Thread

check if string has non-word characters mike <mikaelpetterson@hotmail.com> - 2015-06-16 07:20 -0700
  Re: check if string has non-word characters Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-06-16 11:41 -0400
  Re: check if string has non-word characters Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-06-16 18:42 +0200
  Re: check if string has non-word characters Robert Klemme <shortcutter@googlemail.com> - 2015-06-16 22:58 +0200
  Re: check if string has non-word characters Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2015-06-22 16:13 -0700

csiph-web