Substring and regex

"12/27/23 12 L3670 1.0 189.60 66.40 1 24.64 24.64 98.56"This is my string, i want to get third last value 24.64 from the string, i am using substring and regex pattern for this, but unable to resove this, suggest any suitable substring like i am applying (substring.length-35)35, how i applying this to get this value

HI @Arvind1

(\d+\.\d+)(?=\s*\d+\.\d+$)

Regards

@Arvind1,

You can follow this approach:

  1. Assign strInput = β€œ12/27/23 12 L3670 1.0 189.60 66.40 1 24.64 24.64 98.56”
  2. Assign pattern = β€œ\d+(.\d+)?”
  3. Use Matches Activity
    • Input: strInput
    • Pattern: pattern
    • Result: matches
  4. Assign thirdLastValue = matches(matches.Count - 3).Value

Thanks,
Ashok :slight_smile:

Hi @Arvind1

Regex.Matches(input, "\d+\.\d+").Cast(Of Match)().Select(Function(m) m.Value).Reverse().Skip(2).FirstOrDefault()

HI @Arvind1

xaml:
Sequence10.xaml (7.1 KB)

Regards

Hi @Arvind1

Try this

thirdLastValue = inputString.Split(" "c)(inputString.Split(" "c).Length - 3)

Regards,

@Arvind1

Please check this

Regards,

Hi @Arvind1

str_Input = β€œ12/27/23 12 L3670 1.0 189.60 66.40 1 24.64 24.64 98.56”

Take Assign Activity with Variable lastThirdValue to store the Third Last Value


lastThirdValue = Split(str_Input," ")(Split(str_Input," ").Count-3)



Hope it’ll helps you :slight_smile:
Cheerss!!

no third last value, its gives second last

use the below:

(\d+\.\d+)(?=\s*\d+\.\d+\s*\d+\.\d+$)

@Arvind1

Hi @Arvind1

Check the below xaml

Xaml:
Sequence10.xaml (7.2 KB)

Regards

04/29/24 12 L0650 1.0 1,934.22 497.72 49.77 49.77 447.95
04/15/24 12 E0163NU 1.0 163.48 66.79 66.79
04/15/24 12 E0143NU 1.0 148.58 60.70 60.70
03/21/24 12 L3670LT 1.0 246.40 60.07 60.07 60.07 0.00
12/27/23 12 L3670 1.0 189.60 66.40 1 24.64 24.64 98.56
i want to get third last value from each string

Hi @Arvind1

Check the below xaml for refernce:
Sequence10.xaml (8.3 KB)

Regex:

(\d+\.\d+)(?=\s*\d+\.\d+\s*\d+\.\d+$)

Regards

1 Like

(\d+.\d+)(?=\s*\d+.\d+\s*\d+.\d+$)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.