Jump to content

Help capture part of a string please :)


mds1256

Recommended Posts

I have the following string (the parts between the double quotes is dynamic so not the same length or content each time) and I need to pick out who is logged on only, don't need any of the other content.

 
"explorer.exe","2012","Console","1","30,832 K","Running","MYDOMAIN\Administrator","0:00:02","N/A"
 

Now, I need to get the MYDOMAIN\Administrator part only (not including the quotes) and keep this in a variable.

 
Could someone help me out with this, i'm sure it is fairly easy for one of you regex experts to do.
 
 Thank you.
Link to comment
https://forums.phpfreaks.com/topic/282345-help-capture-part-of-a-string-please/
Share on other sites

I am guilty of often failing to think of solutions like the one proposed by .josh, a neat solution which is a great example of when not to use regex.

For example, with a regex that aimed to retrieve the 7th string by counting commas, the "30,832" would really throw things off.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.