Link to home
Start Free TrialLog in
Avatar of JimiJ13
JimiJ13Flag 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.
ASKER CERTIFIED SOLUTION
Avatar of d_york
d_york

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JimiJ13

ASKER

d_york,

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


Any idea?
Avatar of d_york
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.
Avatar of 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.
Avatar of JimiJ13

ASKER

Thanks for the quick response.