I need to get user names as i highlited. But ı cant figure out how to.
Here is the link. Thank you very much.
A Regex problem
-
- Posts: 104
- Joined: 07 Aug 2015, 15:53
A Regex problem
Last edited by murataygun on 12 Jan 2022, 15:40, edited 1 time in total.
Re: A Regex problem
For the first instance: (?<=\()[^)]*
For the second instance: (?<= : ).*(?= - )
Are they going to be different and you need to get both? Or are you just looking to get one or the other?
For the second instance: (?<= : ).*(?= - )
Are they going to be different and you need to get both? Or are you just looking to get one or the other?
Last edited by boiler on 12 Jan 2022, 11:54, edited 1 time in total.
-
- Posts: 104
- Joined: 07 Aug 2015, 15:53
Re: A Regex problem
Actually, the problem with getting the second name is a problem if we are just trying to isolate that it is preceded with a " : " and followed by a " - ", because that occur elsewhere and would also capture the IP address shown earlier. Will the second instance always be preceded by "Kullanıcı : "?
You need to show some other cases so that we can see what will always be in place. Even "Kullanıcı : " occurs more than once.
You need to show some other cases so that we can see what will always be in place. Even "Kullanıcı : " occurs more than once.
-
- Posts: 104
- Joined: 07 Aug 2015, 15:53
Re: A Regex problem
Yes. "Kullanıcı" will allways be there.boiler wrote: ↑12 Jan 2022, 11:59Actually, the problem with getting the second name is a problem if we are just trying to isolate that it is preceded with a " : " and followed by a " - ", because that occur elsewhere and would also capture the IP address shown earlier. Will the second instance always be preceded by "Kullanıcı : "?
You need to show some other cases so that we can see what will always be in place. Even "Kullanıcı : " occurs more than once.
Last edited by murataygun on 12 Jan 2022, 15:40, edited 1 time in total.
-
- Posts: 104
- Joined: 07 Aug 2015, 15:53
Re: A Regex problem
Updated example
Last edited by murataygun on 12 Jan 2022, 15:40, edited 1 time in total.
-
- Posts: 104
- Joined: 07 Aug 2015, 15:53
Re: A Regex problem
Btw thank you for your timeboiler wrote: ↑12 Jan 2022, 11:59Actually, the problem with getting the second name is a problem if we are just trying to isolate that it is preceded with a " : " and followed by a " - ", because that occur elsewhere and would also capture the IP address shown earlier. Will the second instance always be preceded by "Kullanıcı : "?
You need to show some other cases so that we can see what will always be in place. Even "Kullanıcı : " occurs more than once.
![Angel :angel:](./images/smilies/icon_angel.gif)
Re: A Regex problem
This matches both as two capturing groups: (\([^)]*).*Kullanıcı : (.*) -
You need to have the "s" (single line) option selected.
It works with your latest example to. Make sure the "s" option is selected on that one too.
You need to have the "s" (single line) option selected.
It works with your latest example to. Make sure the "s" option is selected on that one too.
Re: A Regex problem
Correction: \(([^)]*).*Kullanıcı : (.*) -
The previous version had an error that included the open parenthesis in the first result.
The previous version had an error that included the open parenthesis in the first result.
Re: A Regex problem
AHK demonstration:
Code: Select all
Text =
(
Pil Ölçer
Network Flyout
POLİKLİNİK MUAYENE - Kullanıcı : TEM01(BİROL ÖZKAYNAK) - Frm : POLIKLINIK_MUAYENE_ACIL1024 - Ver : 1.0.1 - IP : 10.45.64.58 - Stok : ACIL POLIKLINIĞI
POLİKLİNİK MUAYENE - Kullanıcı : HK1131(MURAT AYGÜN) - Frm : POLIKLINIK_MUAYENE_ACIL1024 - Ver : 1.0.1 - IP : 10.45.64.58 - Stok : ACIL POLIKLINIĞI
ETIKET
VAKA GELİŞİ KAYDI...
Prokalca.exe
tetkik GUI
Poliklinik Defteri - Vers: 1.0.1.520 - Kullanıcı : BİROL ÖZKAYNAK - Stok : ACIL POLIKLINIĞI
Poliklinik Defteri - Vers: 1.0.1.520 - Kullanıcı : MURAT AYGÜN - Stok : ACIL POLIKLINIĞI
ETIKET
)
RegExMatch(Text, "\(([^)]*).*Kullanıcı : (.*) -", Name)
MsgBox, % "Name 1: " Name1 "`nName 2: " Name2
-
- Posts: 104
- Joined: 07 Aug 2015, 15:53
Re: A Regex problem
Am i missing something
Last edited by murataygun on 12 Jan 2022, 15:41, edited 1 time in total.
Re: A Regex problem
Yes, now you've shown a case that doesn't match either of the other two. Now the second name isn't followed by " - ".
You can't show certain cases and then wonder why something that's a different format doesn't also work. If I change it to make it match that one as well, you could easily show another different case where it wouldn't. Do you understand why what's surrounding the name is important? That's how it figures out where to grab it from. It can't magically know where the name starts and ends.
You can't show certain cases and then wonder why something that's a different format doesn't also work. If I change it to make it match that one as well, you could easily show another different case where it wouldn't. Do you understand why what's surrounding the name is important? That's how it figures out where to grab it from. It can't magically know where the name starts and ends.
-
- Posts: 104
- Joined: 07 Aug 2015, 15:53
Re: A Regex problem
But it is followed by " - "
Sorry to bother you but I'm getting windows titles and searching user names on each line. I got 3 different titles which has user names in it. I should collect all.
This covers number 2 and 3.
Code: Select all
(?<= : ).*(?= - )
Code: Select all
(?<=\()[^)]*
Thanks for these codes.
Last edited by murataygun on 12 Jan 2022, 15:41, edited 1 time in total.
Re: A Regex problem
I see now. You're right. Easily addressed by changing the last quantifier to be ungreedy:
\(([^)]*).*Kullanıcı : (.*?) -
\(([^)]*).*Kullanıcı : (.*?) -
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 381 guests