How to pass Regex output to a C# function

Hello i want to pass Parse block output to a C# function
here is my function it works great if i pass a string like “2025-02-17” but I want to use it into Parse block

public string getRemainingDays(string eDate){
 var date = Convert.ToDateTime(eDate, new CultureInfo("en-US"));
     var dateNow = DateTime.Now;
     return (date - dateNow).Days.ToString();
}

but I’m having this error
Capture

Hello @King_Kong
Why don’t you just take the variable in this case parseOutput and add it to your function I don’t understand exactly what you want to do
If it doesn’t work it’s probably that you did something wrong at the level of the parse block or at the level of your function go step by step.
Can this help you?

BLOCK:ConstantString
LABEL:
  value = "2025-02-17"
  => VAR @constantStringOutput
ENDBLOCK

BLOCK:Parse
  input = @constantStringOutput
  MODE:LR
  => VAR @parseOutput
ENDBLOCK


public string getRemainingDays(string eDate)
{
 var date = Convert.ToDateTime(eDate, new CultureInfo("en-US"));
 CLOG BottleGreen date
 var dateNow = DateTime.Now;
 CLOG BottleGreen dateNow
 return (date - dateNow).Days.ToString();
}

string eDate = parseOutput;

var King_Kong = getRemainingDays(eDate);
CLOG BottleGreen King_Kong

Capture

2 Likes

You are active everywhere, thanks for your efforts

1 Like

@WannaCry since I’m using Regex and it’s recursive, so somehow I wanted to adjust my function in output Format so that it may get called for every item automatically

What I advise you to do is to assign the result of your function to a variable then you use this variable as you see fit in the parse block using the interpolated mode
@King_Kong
Then if you want it to do it for each item use a loop and go through the list you generated with your parse block.
Also I think this question would go better in the Coding categories(personal opinion)…

1 Like

@WannaCry Thanks, I’ll try it, and sorry for the wrong category