Text findout


#1

HI text like below but i have to find out % details.

[ /home/oracle ]
oracle@test.local > df -h | grep /u02
20G 8.9G 11G 46% /u02/oradata/rhlab
9.9G 1.4G 8.6G 14% /u02/oraredo/rhlab

[ /home/oracle ]
oracle@test.local >

i want out put like 46 ,14

could you please help on this

Regards,
Raj


#2

Did you tried using Split function?


#3

i tried, but s many values are coming in the output


#4

Hi,

You can use regular expression:

(?<=(G))(\s\d+)(?=(%))

I don’t know how to trim off the space in front of the 46 and 14 within that regex though…can someone help?
Thanks

Lavina


#5

If the % occurs only two times, then it can be extracted using indexOf and substring and lastindexof and substring.


#6

Hi! @lavint can you please message me some links from where I can study Regex. I don’t know how to use them.
Thanks in Advance :slight_smile:


#7

yes… we can use trim. but I am hoping to do it within the regex if anyone knows how~


#8

Hello @Niket_Ghai ,

I am also fairly new to regex but I found this website which is quite helpful to test. It also explains what the expression is doing:

https://regex101.com/

hope it helps :slight_smile:
Lavina


#9

Hi - try this one - https://youtu.be/sa-TUpSx1JA

To test ur regex use this link - https://regex101.com/

Regards,
Nitesh N


#10

i need output 46 or 14 based on /u02/oradata/

could you please help on this regex code


#11

Hi @rajsekhar

This should select what you want:
\d{2}(?=%)

It selects two digits before the % sign.

If you use it with Matches activity, it will return an IEnumerable with the results.


#12

thanks for your input, i need data from multiple line items based on /U02/oradata/


#13

You can extend it by simply including the full line after the % sign (you have to escape the forward slash sign though), like this:
\d{2}(?=% \/u02\/oradata\/rhlab)

This should select any two digits before the:
% /u02/oradata/rhlab


#14

thank very much for your help

/u02/oracle/oradata/OREPOS/datafile/o1_mf_system_d8hocz2r_.dbf

from the test i need 3 separate variables

1.u02
2. oradata
3. o1_mf_system_d8hocz2r_.dbf

could you please help me on this


#15

Can you clarify your question, please?

@loginerror nice help with the Regex! :+1:


#16

i need to capture 3 values from the given line item

Line item is - “/u02/oracle/oradata/OREPOS/datafile/o1_mf_system_d8hocz2r_.dbf”

output of 3 values are

1.u02
2. oradata
3. o1_mf_system_d8hocz2r_.dbf


#17

thanks for your help. i got it
using arrstring.GetValue(1).ToString