0

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

0

2 Answers 2

1
$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.

Sign up to request clarification or add additional context in comments.

1 Comment

@user1734552 If this solved your problem, please accept the solution.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.