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


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

Re: Because ramine plugging comp.programming with spam....

Path csiph.com!aioe.org!.POSTED.O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: Because ramine plugging comp.programming with spam....
Date Wed, 27 Nov 2019 18:31:28 -0500
Organization Aioe.org NNTP Server
Lines 52
Message-ID <qrn10f$1lhd$1@gioia.aioe.org> (permalink)
References <64859ebd-4194-4b36-ae6b-80135a519db2@googlegroups.com>
NNTP-Posting-Host O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1
Content-Language en-US
X-Notice Filtered by postfilter v. 0.9.2
Xref csiph.com comp.lang.java.programmer:39196

Show key headers only | View raw


On 11/27/2019 8:32 AM, chad altenburg wrote:
> This is sort of Java related.
> 
> This is about searching for a word in a Java using regex.
> 
> I have the word "AlarmService".
> 
> 1)searching for "alarm" produces "AlarmService"
> 
> 2)searching for "alarmS" produces nothing
> 
> 3)searching for "AlarmS" produces "AlarmService"
> 
> The question is how come having a lowercase in "a" in 1 produces the entire word
> while the lowercase "a" in 2 doesn't? Ie, I have to change it uppercase in order to get the correct result.

Could you show some code?

Because I cannot recreate the problem.

import java.util.regex.Pattern;

public class RegexMatch {
	public static void test(String needle, String haystack) {
		Pattern p = Pattern.compile(needle);
		System.out.printf("Standard match %s in %s : %b\n", needle, haystack, 
p.matcher(haystack).find());
		Pattern pi = Pattern.compile(needle, Pattern.CASE_INSENSITIVE);
		System.out.printf("Case insensitive match %s in %s : %b\n", needle, 
haystack, pi.matcher(haystack).find());
	}
	public static void main(String[] args) {
		test("alarm", "AlarmService");
		test("alarmS", "AlarmService");
		test("AlarmS", "AlarmService");
	}
}

produces:

Standard match alarm in AlarmService : false
Case insensitive match alarm in AlarmService : true
Standard match alarmS in AlarmService : false
Case insensitive match alarmS in AlarmService : true
Standard match AlarmS in AlarmService : true
Case insensitive match AlarmS in AlarmService : true

which matches my expectations.

Arne

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


Thread

Because ramine plugging comp.programming with spam.... chad altenburg <cdalten@gmail.com> - 2019-11-27 05:32 -0800
  Re: Because ramine plugging comp.programming with spam.... Martin Gregorie <martin@mydomain.invalid> - 2019-11-27 13:47 +0000
    Re: Because ramine plugging comp.programming with spam.... chad altenburg <cdalten@gmail.com> - 2019-11-27 05:59 -0800
      Re: Because ramine plugging comp.programming with spam.... Martin Gregorie <martin@mydomain.invalid> - 2019-11-27 15:02 +0000
        Re: Because ramine plugging comp.programming with spam.... Arne Vajhøj <arne@vajhoej.dk> - 2019-11-27 18:22 -0500
          Re: Because ramine plugging comp.programming with spam.... Martin Gregorie <martin@mydomain.invalid> - 2019-11-27 23:38 +0000
            Re: Because ramine plugging comp.programming with spam.... Arne Vajhøj <arne@vajhoej.dk> - 2019-11-27 20:26 -0500
              Re: Because ramine plugging comp.programming with spam.... chad altenburg <cdalten@gmail.com> - 2019-11-28 08:15 -0800
                Re: Because ramine plugging comp.programming with spam.... chad altenburg <cdalten@gmail.com> - 2019-12-10 10:28 -0800
                Re: Because ramine plugging comp.programming with spam.... chad altenburg <cdalten@gmail.com> - 2019-12-10 10:29 -0800
  Re: Because ramine plugging comp.programming with spam.... Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-11-27 20:09 +0100
    Re: Because ramine plugging comp.programming with spam.... Arne Vajhøj <arne@vajhoej.dk> - 2019-11-27 18:23 -0500
  Re: Because ramine plugging comp.programming with spam.... Arne Vajhøj <arne@vajhoej.dk> - 2019-11-27 18:31 -0500
    Re: Because ramine plugging comp.programming with spam.... Martin Gregorie <martin@mydomain.invalid> - 2019-11-27 23:41 +0000

csiph-web