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.

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature

Reply via email to