Answer the question
In order to leave comments, you need to log in
How to extract text from another text?
I am making a parser on VPN ShadowSocks.
It is necessary to extract the keys themselves from the messages
. Example:
(Какой-то текст) ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpUZXN0UGFzc3dvcmRAdGVzdC5hZGRyZXNzOjc3Nzc=#TestName (Какой-то текст)
ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpUZXN0UGFzc3dvcmRAdGVzdC5hZGRyZXNzOjc3Nzc=#TestName (Какой-то текст)
Answer the question
In order to leave comments, you need to log in
There are at least two ways to solve it:
The first way is to split the lines according to the initial fragment, we get several pieces. We discard the first piece, split the rest along the final fragment and leave the first piece from each - these will be the keys.
The second way is to use regex with the findall method, with a pattern like this:
/(ss:\/\/[a-zA-Z0-9]+=#)/gm.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question