Jump to content

Help capture part of a string please :)


mds1256
Go to solution Solved by .josh,

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.