Parse help

im doing parse from some api response with regex to capture multi results
ticking Recursive inside parse block to get results for IID variable
like in next screen shot

IID

then i do same thing for PD variable and got results like next screen shot too

PD

there’s 6 results in under each variable i could parse both in 1 regex but i have to seperate them because im translating id for names later so i need them alone

now i make last parse block to show them like what i want to achieve
using the variables as in next screen shot to gather them

FULL

as i want to see them like this list one by one like this example

18001:20140419T144107
22002:20150111T042144
86004:20140315T082226
12005:20140419T144150
23002:20140325T170350
103004:20230522T083347

but that wont happen i got that instead

Parsed value: [18001, 22002, 86004, 12005, 23002, 103004]:[20140419T144107, 20150111T042144, 20140315T082226, 20140419T144150, 20140325T170350, 20230522T083347]

like sorting all of IID values then PD not one by one as i want

i cant figure out how to make it like i said

also after that if i want to sort the oldest
date here and parse it how to do that like in here the oldest date

20140315T082226

sorry for long question hope someone help me thanks …

You Can Simply Use This Code

Namespaces

System.Text.RegularExpressions
System.Linq

C# Code

BLOCK:ConstantString
  value = "[18001, 22002, 86004]"
  => VAR @aa
ENDBLOCK

BLOCK:ConstantString
  value = "[20140419T144107, 20150111T042144, 20140315T082226]"
  => VAR @bb
ENDBLOCK

string Num1 = $"{aa}";
string Num2 = $"{bb}";

string[] ExtractValues(string input)
{
    var match = Regex.Match(input, @"\[(.*?)\]");
    return match.Groups[1].Value.Split(',').Select(s => s.Trim()).ToArray();
}

var Num11 = ExtractValues(Num1);
var Num22 = ExtractValues(Num2);
var combined = Num11.Zip(Num22, (Fnum, Snum) => $"{Fnum}:{Snum}");

string result = $"[{string.Join(", ", combined)}]";

Dont Forget To Put You Variables In The Constant String

2 Likes

You can also use the zip block to merge the two lists, item by item, into a single list, then you process those individually in a foreach loop

1 Like

thanks for the help what about the oldest date part ?
how to capture the oldest date value from those after
like here in example its the oldest date one
86004:20140315T082226

You need to use C# for this, after you’ve joined the lists you can use the MaxBy Linq method.

1 Like

can i get more explain please ?

ok its worked fine , but the result is just custom lolicode , how to make it ( is capture )
like in parse blocks !

MARK @result
1 Like

what about sorting the oldest date part look up please and need help too ?

u want to start with old dates, then go to newest ones?

1 Like

i want to capture only 1 value ( oldest date from them ) like i put the example
or whatever if there’s another method to sort them from old to new its ok too could be easier to find out the oldest one by look instead of random sorting

This code to sort the list from oldest to newest dates

string Num1 = $"{aa}";
string Num2 = $"{bb}";
string[] ExtractValues(string input)
{
    var match = Regex.Match(input, @"\[(.*?)\]");
    return match.Groups[1].Value.Split(',').Select(s => s.Trim()).ToArray();
}

DateTime ParseDate(string dateString)
{
    return DateTime.ParseExact(dateString, "yyyyMMddTHHmmss", null);
}
var Num11 = ExtractValues(Num1);
var Num22 = ExtractValues(Num2);
var combined = Num11.Zip(Num22, (Fnum, Snum) => new { Fnum, Snum })
    .OrderBy(pair => ParseDate(pair.Snum))
    .Select(pair => $"{pair.Fnum}:{pair.Snum}");

string result = $"[{string.Join(", ", combined)}]";


MARK @result

and this one to get only the oldest date

BLOCK:ConstantString
  value = "[18001, 22002, 86004]"
  => VAR @aa
ENDBLOCK

BLOCK:ConstantString
  value = "[20130419T144107, 20150111T042144, 20140315T082226]"
  => VAR @bb
ENDBLOCK


string Num1 = $"{aa}";
string Num2 = $"{bb}";

string[] ExtractValues(string input)
{
    var match = Regex.Match(input, @"\[(.*?)\]");
    return match.Groups[1].Value.Split(',').Select(s => s.Trim()).ToArray();
}

DateTime ParseDate(string dateString)
{
    return DateTime.ParseExact(dateString, "yyyyMMddTHHmmss", null);
}

var Num11 = ExtractValues(Num1);
var Num22 = ExtractValues(Num2);
var oldestPair = Num11.Zip(Num22, (Fnum, Snum) => new { Fnum, Snum })
    .OrderBy(pair => ParseDate(pair.Snum)) 
    .First();

string result = $"{oldestPair.Fnum}:{oldestPair.Snum}";




MARK @result

2 Likes

insane bro thanks so much , worked without single proplem
easy task , just last thing i want to achieve then im gucci
how to make the date format finally show like this yyyy-mm-dd/hh-mm-ss
in mark @result
and you have to know there’s (T) letter in place of ( / ) i want to change

1 Like

Here

BLOCK:ConstantString
  value = "[18001, 22002, 86004]"
  => VAR @aa
ENDBLOCK

BLOCK:ConstantString
  value = "[20130419T144107, 20150111T042144, 20140315T082226]"
  => VAR @bb
ENDBLOCK


string Num1 = $"{aa}";
string Num2 = $"{bb}";

string[] ExtractValues(string input)
{
    var match = Regex.Match(input, @"\[(.*?)\]");
    return match.Groups[1].Value.Split(',').Select(s => s.Trim()).ToArray();
}

DateTime ParseDate(string dateString)
{
    return DateTime.ParseExact(dateString, "yyyyMMddTHHmmss", null);
}

var Num11 = ExtractValues(Num1);
var Num22 = ExtractValues(Num2);
var oldestPair = Num11.Zip(Num22, (Fnum, Snum) => new { Fnum, Snum })
    .OrderBy(pair => ParseDate(pair.Snum)) 
    .First();

string formattedDate = ParseDate(oldestPair.Snum).ToString("yyyy-MM-dd/HH-mm-ss");

string result = $"{oldestPair.Fnum}:{formattedDate}";




MARK @result
3 Likes

well well well you rock bro thanks i appericate it so much <3