On Sat, Apr 16, 2022, 11:12 AM <to...@tuxteam.de> wrote:

> On Sat, Apr 16, 2022 at 11:01:17AM -0500, Nicholas Geovanis wrote:
> > On Fri, Apr 15, 2022, 9:37 PM wilson <i...@bigcount.xyz> wrote:
> >
> > > Hello
> > >
> > > in shell script, how can I use regex to extract values from a string?
> > > maybe value types transformation should be required.
> > >
> > >
> > > for instance the string: "black berry 12".
> > > I want go get the name: black berry [String]
> > > the price: 12 [Int]
> > >
> >
> > So you have programming language skills. Look at the info-command-based
> doc
> > for bash. Read the sections about shell pattern-matching operators.
> Realize
> > that there are more than one type of that. For example the crippled
> > filename pattern matching on many commands, not really regular
> expressions.
>
> FWIW, bash has an =~ operator for regex matching whithin [[ ]]. There are
> even special variables to pick up the capturing matches.
> Not portable, but arrays (which have been warmly recommended around here)
> aren't, either.
>

I didn't want to spoil the party and say this. But now my hand is forced :-)
You Mr Original Poster may find perl to be more congenial for regular
expression use especially. You should find it on every single platform you
find bash. Regardless of OS.

Cheers
> --
> t
>

Reply via email to