Split a string containing text and date

I have this string with some text, date, more text and numbers like(uses ¤ as a separator to get text later)
"¤bla 123456 bla bla ¤ 31-OCT-19 lastname, firstname ¤bla ¤123456 bla bla ¤
Tried to split with [0-9]{2}-[a-z]{3,}-[0-9]{2} but I can not figure it how to split so I keep the part from date:
31-OCT-19 lastname, firstname ¤bla ¤123456 bla bla
regards

@kare.smorvik
Try with this regex expresssion,

\d{2}-[A-z]{3}-\d{2,4}

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.Match(strData,"(?<=¤)\s*[0-9]{2}-[A-z]{3,}-[0-9]{2}.*?¤.*(?=¤)")

Regards,

Thank tou, looks like it works, but could you pleas explain what it does? So I can learn a little bit moore to understand.
Like what to write if I dont’t know how long the text is after date. I Guess if I use a For Each it will read every instanse of date as a new string?

regards

Hi,

could you pleas explain what it does? So I can learn a little bit moore to understand.

(?<=¤) : Positive lookbehind of Regex. If there is ¤, behind string is matched
\s* : Match 0 or some whitespaces
[0-9]{2}-[A-z]{3,}-[0-9]{2} : date
.*?¤ : Match 0 or some characters and ¤ (Shortest match)
.* Match 0 or some characters
(?=¤) : Positive lookahead of Regex. If there is ¤, head string is matched

Like what to write if I dont’t know how long the text is after date. I Guess if I use a For Each it will read every instanse of date as a new string?

Probably it doesn’t depend on text length. But I suppose you need to test in various cases which you estimate.

Regards,

Thanks a lot. Trying to test now. Find the first date, but the string output is a little wrong. I think I need to take all text after first date and keep it in a sting, then it will loop for every instans of date it that string.(Sorry about my crap english)

regards

Hi,

I think I need to take all text after first date and keep it in a sting,

Can you try the following pattern?
(?<=¤)\s*[0-9]{2}-[A-z]{3,}-[0-9]{2}.*$

Regards,

Does not return any thing:)

Hi,

Does your string end with line break?
If so, it might be the following.

(?<=¤)\s*[0-9]{2}-[A-z]{3,}-[0-9]{2}[¥s¥S]*$

Regards,

This one works, splits the line, but I lost the date. How do I keep the date as first part of each substring?

Hope this expression would work with all conditions
\d{1,4}-[A-Za-z]{3,10}-\d{2,4}
Like
1-Oct-19
1-OCT-19
01-OCT-19
01-OCT-2019
01-OCTOBER-2019
01-October-19

Any date format

Kindly try this and let know for any queries or clarification
Cheers @kare.smorvik