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


Groups > comp.lang.java.help > #4204

Re: Regx problem

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.help
Subject Re: Regx problem
Date 2017-08-27 15:17 -0400
Organization A noiseless patient Spider
Message-ID <onv5ja$iab$1@dont-email.me> (permalink)
References <hhr5qcpbuc0fcajj5hnvuegtgv50ou5vpq@4ax.com>

Show all headers | View raw


On 8/27/2017 12:17 PM, IchBin wrote:
> I have always had a hard time with regx. Even the simple things like
> this one. All I want to do is replace a string with another string. In
> this case a ' replaced with ''.

     The problem you describe can be solved without using regular
expressions at all:

	String original = ...;
	String replaced = original.replace("'", "''");

> I am trying:
>   rsNname = rsNname.replaceAll("\\d \\D \\W \\w \\S \\s", "''");
>   rsNname = rsNname.replaceAll("[+.-^]", "''");
>   rsNname = rsNname.replaceAll("[$&+,:;=?@#|'<>.^*()%!-]", "''");
> rsNname = rsNname.replaceAll("['++]", "\\''");
> 
> Nomatter what I do I get a compli error "Derefferencing pointer
> error". Any one have any suggestions.

     No, not without (1) the code you are trying to compile and
(2) the *exact* error message or messages the compiler emits.

> I could write code to do the same but seems better to do in one
> commane.

     It's not clear to me what "do the same" means.  The replaceAll()
calls you show seem to have nothing to do with the problem you say
you are trying to solve -- in fact, some of them are nonsensical to
the point that I think they would throw exceptions at run-time (not
compile-time).  If the replace() call above doesn't meet your needs,
please show your actual code and your actual error messages, and
give a fuller description of what you're trying to do.

-- 
esosman@comcast-dot-net.invalid
Twelve hundred forty-two days to go.

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Regx problem IchBin - 2017-08-27 12:17 -0400
  Re: Regx problem Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-27 15:17 -0400
    Re: Regx problem IchBin - 2017-08-28 09:13 -0400
  Re: Regx problem IchBin - 2017-08-27 16:30 -0400
    Re: Regx problem Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-27 16:53 -0400

csiph-web