all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* regex with [_A-Z] not working as I expect
@ 2012-05-10 10:28 AngusC
  2012-05-10 17:13 ` "Jérôme M. Berger"
  2012-05-10 17:15 ` Peter Dyballa
  0 siblings, 2 replies; 3+ messages in thread
From: AngusC @ 2012-05-10 10:28 UTC (permalink / raw)
  To: Help-gnu-emacs


I expected to be able to do things like this:

Example text to find
1, Passed,0,Q_Mitel2_with_hub_Env1,1,
1, Passed,0,Q_Mitel2_with_hub_Env2,1,
1, Passed,0,Q_Mitel2_with_hub_Env3,1,

But if my regex search string is
^1, Passed,0,[_A-Za-z0-9]

Then it only finds text up to 1, Passed,0,Q

How do I get it to find all of text like A_BC_D and A_CCCCCC_S
-- 
View this message in context: http://old.nabble.com/regex-with--_A-Z--not-working-as-I-expect-tp33763671p33763671.html
Sent from the Emacs - Help mailing list archive at Nabble.com.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: regex with [_A-Z] not working as I expect
  2012-05-10 10:28 regex with [_A-Z] not working as I expect AngusC
@ 2012-05-10 17:13 ` "Jérôme M. Berger"
  2012-05-10 17:15 ` Peter Dyballa
  1 sibling, 0 replies; 3+ messages in thread
From: "Jérôme M. Berger" @ 2012-05-10 17:13 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 770 bytes --]

AngusC wrote:
> I expected to be able to do things like this:
> 
> Example text to find
> 1, Passed,0,Q_Mitel2_with_hub_Env1,1,
> 1, Passed,0,Q_Mitel2_with_hub_Env2,1,
> 1, Passed,0,Q_Mitel2_with_hub_Env3,1,
> 
> But if my regex search string is
> ^1, Passed,0,[_A-Za-z0-9]
> 
> Then it only finds text up to 1, Passed,0,Q
> 
> How do I get it to find all of text like A_BC_D and A_CCCCCC_S

	Putting a set of characters between square brackets will only match
one character from the set. You can then use the usual repetition
operators (?, *, or +) to match more than one character (so in your
case, ^1, Passed,0,[_A-Za-z0-9]+ should do what you want).

		Jerome
-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: regex with [_A-Z] not working as I expect
  2012-05-10 10:28 regex with [_A-Z] not working as I expect AngusC
  2012-05-10 17:13 ` "Jérôme M. Berger"
@ 2012-05-10 17:15 ` Peter Dyballa
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Dyballa @ 2012-05-10 17:15 UTC (permalink / raw)
  To: AngusC; +Cc: Help-gnu-emacs


Am 10.05.2012 um 12:28 schrieb AngusC:

> But if my regex search string is
> ^1, Passed,0,[_A-Za-z0-9]
> 
> Then it only finds text up to 1, Passed,0,Q

That is correct behaviour! It finds exactly one character of the given set. If you want to find more, you need to add a + for example.

--
Greetings

  Pete

I hope to die before I *have* to use Microsoft Word.
			- Donald E. Knuth, 2001-10-02 in Tübingen




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-10 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-10 10:28 regex with [_A-Z] not working as I expect AngusC
2012-05-10 17:13 ` "Jérôme M. Berger"
2012-05-10 17:15 ` Peter Dyballa

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.