Text findout

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

Did you tried using Split function?

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

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

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

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:

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

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:

hope it helps :slight_smile:
Lavina

1 Like

Hi - try this one - Regular Expressions (Regex) Tutorial: How to Match Any Pattern of Text - YouTube

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

Regards,
Nitesh N

1 Like

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

could you please help on this regex code

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.

3 Likes

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

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

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

Can you clarify your question, please?

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

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

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