Regex variable "Null" when trying to debug

I have the workflow I needed to debug:

  1. MEInfo2 variable has below regex:

System.Text.RegularExpressions.Regex.Match(MEInfo,“(?<=MAIN ENGINE\s)(.+?(?=\sAUXILIARY|\sPROPULSOR|\sPOS|\sOTHER|\sCARGO|\sENVIRONMENTAL|\sENERGY|\sLIFTING|\sBOILER|\sEMERGENCY))”).ToString.Trim

  1. MESplitArray has below regex:

System.Text.RegularExpressions.Regex.Split(MEInfo2,“.\s(?=\d\sx)”)

Below is the data that will be used for extract:

MAIN ENGINE 2 x Diesel - WinGD 6X72DF - 2-stroke 6-cyl. 720mm x3086mm bore/stroke 26,530mkW total at 69.10rpm.
AUXILIARY 2 x Aux. Diesel Gen. - 4-stroke driving 2 x HD Hyundai Electric HSJ9 811-10P - AC generator(s) at 7,380ekW total, (9,225kVA total) 6600V at 50Hz. 2 x Aux. Diesel Gen. - 4-stroke driving 2 x HD Hyundai Electric HSJ9 803-10P - AC generator(s) at 5,540ekW total, (6,925kVA total) 6600V at 50Hz.
PROPULSOR 2 x FP Propeller (Aft) (mechanical), 69.10rpm.
OTHER ENGINE EQUIPMENT 2 x Screw Shaft.
ENVIRONMENTAL EQUIPMENT 2 x Selective Catalytic Reduction - NOx - Unknown. 2 x BWTS - Ballast Water Treatment System - SunRui BC-3000 at 3000cu.m/hr.
EMERGENCY 1 x Emergency Diesel Gen. - 4-stroke driving 1 x ac generator(s) at 50Hz.

When I run in debug mode, the MESplitArray is “Null”, I am trying to understand what this variable does and why is it Null.

The variable MESplitArray will later be used in For Each:

Hi @Irfan_Musa

Try the below one:

  1. MEInfo2 variable has below regex:
MEInfo2 = System.Text.RegularExpressions.Regex.Match(MEInfo,"(?<=MAIN ENGINE\s)(.+?(?=\sAUXILIARY|\sPROPULSOR|\sPOS|\sOTHER|\sCARGO|\sENVIRONMENTAL|\sENERGY|\sLIFTING|\sBOILER|\sEMERGENCY))").Value.Trim
  1. MESplitArray has below regex:
MESplitArray= System.Text.RegularExpressions.Regex.Split(MEInfo2,".\s(?=\d\sx)")

Hope it helps!!

Hi,

In my environment, your expression returns the following result. (But number of items is 1)

Can you share your expected output?

Regards,

@Yoichi , the screenshot is the desired output , as per my understanding the info after “MAIN ENGINE” will be further breakdown to smaller pieces in the For Each

Hi,

Can you share specific expected output?

Regards,

Hi @Irfan_Musa

Actually your split condition is returning null value. Can I know what are you trying to split from the before result so that I can help you with the modified condition.

Regards

The desired output is this part:

2 x Diesel - WinGD 6X72DF - 2-stroke 6-cyl. 720mm x3086mm bore/stroke 26,530mkW total at 69.10rpm

From my end the result is showing this :
image

The desired output is this part:

2 x Diesel - WinGD 6X72DF - 2-stroke 6-cyl. 720mm x3086mm bore/stroke 26,530mkW total at 69.10rpm

From my end the result is showing this :
image

HI,

For now can you try the following sample?

Sample20231023-4L.zip (2.8 KB)

If it works well, can you check difference of them?

Regards,

@Irfan_Musa

What is your expected output of your SplitArray. Specify.

Regards

In my regex expression it has a "" at the front. I tried removing it and it still gives the same “null” result

I am not sure why the forward slash "\ " is not showing

Hi,

It’s forum specification as Back slash is special character.

Can you try to remove back slash just before .? . means any character but \. means dot literal.

Or can you share your workflow as file?

Regards,

I am not entirely sure but this is the part is the desired output:

2 x Diesel - WinGD 6X72DF - 2-stroke 6-cyl. 720mm x3086mm bore/stroke 26,530mkW total at 69.10rpm

It will be use in For Each for If:

For Else:

And it will break down further with For Each variable in RegexMENO:

Hi,

if expected output :

2 x Diesel - WinGD 6X72DF - 2-stroke 6-cyl. 720mm x3086mm bore/stroke 26,530mkW total at 69.10rpm

can you check this regex regex101: build, test, and debug regex

Thankyou

Hi @Irfan_Musa

Try the below one:

  1. MEInfo2 variable has below regex:
MEInfo2 = System.Text.RegularExpressions.Regex.Match(MEInfo,"(?<=MAIN ENGINE\s)(.+?(?=\sAUXILIARY|\sPROPULSOR|\sPOS|\sOTHER|\sCARGO|\sENVIRONMENTAL|\sENERGY|\sLIFTING|\sBOILER|\sEMERGENCY))").ToString.Trim

MEInfo2 is of DataType IEnumberable(System.Text.RegularExpression.Match)

Use this variable i.e MEInfo2 in For Each.

Hope it helps!!

Hi @Yoichi ,

I have removed it and it still shows “null”
I can’t share my workflow since it has credentials info.

I can share some screenshot of my currentwork flow:

Variable MEInfo2:

MESplitArray :

For Each with IF:

For Each with Else:

For Each within var RegexMENo:

HI,

it may be line break matter. Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(MEInfo,"(?<=MAIN ENGINE\s+)(.+?(?=\s+AUXILIARY|\s+PROPULSOR|\s+POS|\s+OTHER|\s+CARGO|\s+ENVIRONMENTAL|\s+ENERGY|\s+LIFTING|\s+BOILER|\s+EMERGENCY))").ToString.Trim

Regards,