Sscanf() skip elements

77 views
Skip to first unread message

Daniel Gorbe

unread,
Apr 10, 2020, 1:17:53 PM4/10/20
to golang-nuts

Hi!


It is possible to skip elements of a string with Sscanf()? As in C with %*s.

Example:

    var res string

    text := "A simple text"

    fmt.Sscanf(text, "%*s %*s %s", &res)

    fmt.Printf("%s\n", res) // print: "text"


Best regards,

    Daniel

-- 
Daniel Gorbe
GNU/Linux System Administrator - IT Security Specialist
PGP: 0x5AEB729B3E642A16
Web: https://danielgorbe.com
signature.asc

Ian Lance Taylor

unread,
Apr 10, 2020, 2:09:29 PM4/10/20
to Daniel Gorbe, golang-nuts
On Fri, Apr 10, 2020 at 10:17 AM 'Daniel Gorbe' via golang-nuts
<golan...@googlegroups.com> wrote:
>
> It is possible to skip elements of a string with Sscanf()? As in C with %*s.
>
> Example:
>
> var res string
>
> text := "A simple text"
>
> fmt.Sscanf(text, "%*s %*s %s", &res)
>
> fmt.Printf("%s\n", res) // print: "text"

No, at present there doesn't seem to be any support for that.

Ian

simon place

unread,
May 19, 2020, 2:22:01 PM5/19/20
to golang-nuts
Reply all
Reply to author
Forward
0 new messages