I am trying to return the part of a string, I want to return everything before the fist slash: / P>
EC 22 9 41C / 02 / ORI I should give: EC 22 9 41C
I created my own expression Used to:
(EC. +?) \ /.+ when tested against my text:
EC22941C / 02 / ORI this tells me correctly The first group
EC22941C When I put it in C #:
public static string GetInstructionRef ( String Supplier ID) {// instruciton ref slash var match = reges. Match (SupplierID, @ "(EC + +) \ / .+") is before; If (match == faucet = match.group.count == 0) returns ""; // Return the first group, which is the reference riff return match. Group [0]. Value; } The result I am back is:
EC22941C / 02 / ORI I tried a number
itemprop = "text">
The problem is that you have an incorrect group index Returning, 0 will return the entire match, while returns the matching reference to 1 capturing bracket & mdash; Count from left to right
returns match group 1]. Value;
No comments:
Post a Comment