4
4
4upik2018-03-07 15:11:05
Perl
4upik, 2018-03-07 15:11:05

How to trim text to a specific character using regular expressions in Perl?

How to get from text :
text123 (text 123)
:
text123
also need to trim text to 5 characters
from
texttext texttext123
get
textt

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pcdesign, 2018-03-07
@pcdesign

And you don't need a regex for that. Enough susbstr

print substr("text123 (text 123)",0, 7);
# Результат text123
print substr("texttext texttext123",0, 5);
# Результат textt

A
Alexander, 2018-03-07
@zkelo

Regex101

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question