ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match Pattern labview

Hi,

 

I am new in labview, and I am trying to search some Process id from a string:

 

 

 

Microsoft Windows XP [Version 5.1.2600]

(C) Copyright 1985-2001 Microsoft Corp.

 

c:\> tasklist /fi "imagename eq notepad.exe"

 

Image Name                   PID Session Name     Session#    Mem Usage

========================= ====== ================ ======== ============

notepad.exe                 2964 Console                 0        728 K

notepad.exe                 2432 Console                 0      1,044 K

 

 

 

what I want to get is these PID: 2964 and 2432. I have tried to use multiply string functions, but I think this one can make it. 

 

Can someone help me set up the regular expression? Thanks in advance. 

0 Kudos
Message 1 of 11
(4,455 Views)

George,

 

The forum is not normaly devoted o doing a student's homework.

 

We like to share thoughts with fellow NI enthusiasts! Even those that are new to NI or (on this forum) LabVIEW.  Reply with own question, your Prof's URL, or do your own homework!


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 11
(4,447 Views)

Hello George_Z

 

       Have you tried using array functions where you need to give the no.of column and can vary no. of rows to get what you want. Hope it helps...

I

0 Kudos
Message 3 of 11
(4,431 Views)

Hi George,

 

Read your text from the line that looks like the header for the information contained below [Image Name                   PID Session Name     Session#    Mem Usage].

 

Put this data into a 2D Str Arr. Index the 1st column alone as a 1D Str Arr. Then take the word PID from its 0th element. In the same array look for the word ' Console' ['\sConsole] using the Match pattern function & take out the portion of the Str found before the match.

 

Look carefully that I have included a Space ('\s') character along with the pattern to be looked for and matched.

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 4 of 11
(4,428 Views)

regexp.png

 

This assumes that you'll always have " Console" before the PID.

 

I have a suspicion that there's a better Regexp, but I can't do it.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 11
(4,415 Views)
Here is a cool solution to your problem. Should work with Labview 8+


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 6 of 11
(4,398 Views)

Coq rouge wrote:
Here is a cool solution to your problem. Should work with Labview 8+

 

 

😞

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 7 of 11
(4,379 Views)
Did it not work?


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 8 of 11
(4,377 Views)

Coq rouge wrote:
Did it not work?

Well, it doesn't do what the poster originally asked for, and it also does not place a tab between the process ID and the Session Name. Other than that, it works just fine. Smiley Wink

0 Kudos
Message 9 of 11
(4,358 Views)
Well my solution is some kind of a more general type I shall admit ;). Also if George_Z  wants the pid he can just index the correct cell and convert the PID+Session name to a number. I did that on purpose. I could not solve his entirely assignmentSmiley Very Happy


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 10 of 11
(4,352 Views)