Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #247298
| From | <tomas@tuxteam.de> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: extract values from a string |
| Date | 2022-04-16 18:20 +0200 |
| Message-ID | <EcTjr-99Yk-11@gated-at.bofh.it> (permalink) |
| References | <EcGvU-92e4-15@gated-at.bofh.it> <EcT9L-99V9-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On Sat, Apr 16, 2022 at 11:01:17AM -0500, Nicholas Geovanis wrote: > On Fri, Apr 15, 2022, 9:37 PM wilson <info@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
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
extract values from a string wilson <info@bigcount.xyz> - 2022-04-16 04:40 +0200
Re: extract values from a string Greg Wooledge <greg@wooledge.org> - 2022-04-16 05:10 +0200
Re: extract values from a string Nicholas Geovanis <nickgeovanis@gmail.com> - 2022-04-16 18:10 +0200
Re: extract values from a string <tomas@tuxteam.de> - 2022-04-16 18:20 +0200
Re: extract values from a string Nicholas Geovanis <nickgeovanis@gmail.com> - 2022-04-16 18:50 +0200
Re: extract values from a string Greg Wooledge <greg@wooledge.org> - 2022-04-16 19:30 +0200
Re: extract values from a string Kent West <westk@acu.edu> - 2022-04-17 04:30 +0200
Re: extract values from a string Greg Wooledge <greg@wooledge.org> - 2022-04-17 05:00 +0200
Re: extract values from a string David Christensen <dpchrist@holgerdanske.com> - 2022-04-16 21:30 +0200
Re: extract values from a string Ash Joubert <ash@transient.nz> - 2022-04-17 02:40 +0200
Re: extract values from a string Ash Joubert <ash@transient.nz> - 2022-04-17 02:40 +0200
Re: extract values from a string Greg Wooledge <greg@wooledge.org> - 2022-04-17 02:40 +0200
Re: extract values from a string Ash Joubert <ash@transient.nz> - 2022-04-17 02:50 +0200
csiph-web