Avatar of JimiJ13
JimiJ13
Flag for Philippines asked on

How to extract value from Data pattern

Hello Experts,

How can I extract numbers from the following strings:

"P:200:4401:25:000565 | Sanar Co | 1045 | IMR"   -- Extract 1045
"P/200/6401/35:000665 | Sanar Co | 1046 | IMR" -- Extract 1046
"P-500-6401-45-555665 | Sanar Co | 1049 | IMR" -- Extract 1049

Thanks.
C#

Avatar of undefined
Last Comment
JimiJ13

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
d_york

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
JimiJ13

ASKER
d_york,

Thanks. Actually, that's already my existing solution but, that doesn't work with "/", "-", & ":" present in the string.


Any idea?
d_york

works in English in C# .Net for all those strings - those are not metacharacters.  I hate to say "normal" but this should work on a "normal" setup without issue.  Something else is going on, you've got more going on than a simple set of pipe delimited lines of text.  You'll probably have to divulge more information to get assistance from those more worldly than me.  But if I were just handed this issue to debug in code I'd be looking at:
1) Encoding:  If I'm reading delimited text from file am I really getting what I think I'm getting?  I'd be looking at the language and the encoding being detected.
2)  Operators:  If I've got particular issues around the characters you mention I'd be thinking they are being treated as operators somewhere in the code.  And what I'm getting isn't a "string" but an object like a DateTime or Double or something.
3)  Dev Environment:  I'd suspect the coder was maybe coding toward Mono on Linux or something and it's a compiler or other issue.

Based just on what you posted, I had zero issue splitting those lines of text and converting the third element to an Int.  But I'm "seeing" plain text in English - I'm not seeing all the other factors that could be in play here.
JimiJ13

ASKER
d_york,

You are correct. I traced the issue on the Dot Net coding that concatenated the string thereby resulted to erroneous data extraction.  
 

Thanks.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
JimiJ13

ASKER
Thanks for the quick response.