Re: [go-nuts] Regexp for matching Interface address

2021-04-01 Thread Sharan Guhan
> If you really want to use a regexp, I'd use > `0{4}:[0-9a-f]{2}:0{2}\.[0-9]` > With the caveat, of course, that I have no idea if your example is > exhaustive (i.e. you might have to replace the 0's with [0-9a-f] as well). > > https://play.golang.org/p/DX5RNg6iQTS > > &

[go-nuts] Regexp for matching Interface address

2021-04-01 Thread Sharan Guhan
Hi Experts, I am facing issues in getting the correct regexp for this use-case. Sorry for the 2nd question of the day :-( pci@:19:00.0 pci@:19:00.1 pci@:5e:00.2 pci@:5e:00.3 pci@:d8:00.0 pci@:d8:00.1 I need to fetch ":19:00.0" through ":d8:00.1" in a string.. I

Re: [go-nuts] string matching

2021-04-01 Thread Sharan Guhan
sed solution suggested by > others leads to less code. This input string is so short that CPU > usage will be negligible for most purposes, outweighed by graceful > error handling and code maintenance concerns. > > Best regards, > Michael > > > On Thu, Apr 1, 2021

[go-nuts] string matching

2021-04-01 Thread Sharan Guhan
Hi Experts, New to Golang and finding it non trivial to achieve the below efficiently :-) Any pointers will help.. I have a huge string as below .. Now from this I want to extract the number "18" after "Core count".. I was thinking of walking through each string with Spilt("\n"), but that will

Re: [go-nuts] Searching recursively in GOLANG

2021-03-16 Thread Sharan Guhan
Thanks for the tip! I just wanted to make sure, I am not missing some basic API out there.. Will code this up :-) Sharan On Mon, Mar 15, 2021 at 11:18 PM Jan Mercl <0xj...@gmail.com> wrote: > On Tue, Mar 16, 2021 at 7:06 AM Sharan Guhan wrote: > > > Seems a trivial problem,

[go-nuts] Searching recursively in GOLANG

2021-03-16 Thread Sharan Guhan
Hi Experts, Seems a trivial problem, but unable to find the right imports to do this.. Want to search for a substring in a huge string ( output of a exec.command) and get the index for every occurrence of that substring. I used Index and LastIndex, both give first and last, but am looking for

Re: [go-nuts] Error while executing exec.command

2021-03-16 Thread Sharan Guhan
cat`. The > latter is pointless overhead and unnecessarily fragile. > > On Mon, Mar 15, 2021 at 11:40 PM Amit Saha wrote: > >> >> >> On Tue, 16 Mar 2021, 9:37 am Sharan Guhan, wrote: >> >>> Hi Experts, >>> >>> I am relatively new to GOLANG

[go-nuts] Error while executing exec.command

2021-03-15 Thread Sharan Guhan
Hi Experts, I am relatively new to GOLANG and trying a simple program as below which is failing in fetching the output of a file, which works otherwise on the command prompt: Lang : GOLANG OS : Linux/Centos Problem : Using exec.command to get the output of a certain file Error: Getting no such