On Thu, Jun 19, 2014 at 12:31:51AM +0000, SomeRiz via Digitalmars-d-learn wrote:
> Hi Justin thank you.
> 
> I'm using
> 
> executeShell(a);
> 
> Output:
> 
> ProcessOutput(0, "SerialNumber    \r\r\n92716002xxxx \r\r\n\r\r\n")
> 
> How do I delete ProcessOutPut, 0, SerialNumber, \r,\n text?
> 
> I want to see just out: 92716002xxxx
> 
> Sorry for my bad english :(

Try this:

        import std.regex;
        string extractSerial(string input) {
                auto m = input.match(`SerialNumber\s+(\S+)\s+`);
                if (m)
                        return m.captures[1];
                else
                        throw new Exception("Could not find serial number");
        }

        auto input = "SerialNumber    \r\r\n92716002xxxx \r\r\n\r\r\n";
        writeln(extractSerial(input)); // prints "92716002xxxx"

Hope this helps.


T

-- 
You have to expect the unexpected. -- RL

Reply via email to