Page 1 of 1

Little help with RegEx again...

Posted: November 21st, 2012, 5:16 pm
by LeftSide
So I have a list

Code: Select all

Work
Work
Fire
Global
And I want just the first letters from each line.

Code: Select all

WWFG
The list is created by a batch script

Code: Select all

echo %1>>
I've tried this

Code: Select all

([a-z])[^\n]+\n*
but it gives me just an F

Re: Little help with RegEx again...

Posted: November 21st, 2012, 6:59 pm
by moshi
try:

Code: Select all

(?siU)(?(?=.)(.))(?(?=.*\n).*\n(.))(?(?=.*\n).*\n(.))(?(?=.*\n).*\n(.))

repeat the

Code: Select all

(?(?=.*\n).*\n(.))
as often as you need.

Re: Little help with RegEx again...

Posted: November 21st, 2012, 7:06 pm
by LeftSide
Thanks. BTW
moshi wrote:repeat the

Code: Select all

(?(?=.*\n).*\n(.))
as often as you need.
In this approach, if I don't know just exactly how many times I need to use it in advance it sometimes gives me nothing at all...[/strike]

Nvm. It works flawlessly.