Reputation: 21
Small question regrading taking part of string. my string is
some text here value: 100 .1.3.6 bla bla.
I would like to save the first part of the sting till the .1.3.......
so at the end ill have only
some text here value: 100
Upvotes: 0
Views: 98
Reputation: 54392
This may be what you're looking for (assuming there's only one :
per line).
perl -pe 's/(.*: [^ ]+).*/$1/' file.txt
Result:
some text here value: 100
Upvotes: 1
Reputation: 7516
$str="some text here value: 100 .1.3.6 bla bla.";$str=~m{^([^.]*)} and print $1'
This matches from the beginning of the string until a dot character appears. The matched portion is captured and printed if there was a match.
Upvotes: 1