It is currently March 28th, 2024, 9:54 pm

Little help with RegEx again...

General topics related to Rainmeter.
LeftSide
Posts: 35
Joined: July 3rd, 2012, 6:16 pm

Little help with RegEx again...

Post 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
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Little help with RegEx again...

Post 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.
LeftSide
Posts: 35
Joined: July 3rd, 2012, 6:16 pm

Re: Little help with RegEx again...

Post 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.