R
R
Ruslan Yudin2015-07-07 20:43:58
Java
Ruslan Yudin, 2015-07-07 20:43:58

How to get substring using regular expression?

Hello. I'm trying to process the response string from the VKontakte server. Getting records from the wall. How can you process user mentions in it? The whole entry looks like this: "gewgweg ewwegoih #ihogewig #oihgeirgih [durov|iojfeirjfwe]". From [ to ] mention. What I need to do is to replace the substring from [ to ] with "everything inside after |" (vk.com/everything up to |" (without quotes). How can I do this? Now I'm doing this, the in = in.replaceAll("\\[(.*?)\\]", "упоминание");
mention is replaced. But this is not quite what I need.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MiiNiPaa, 2015-07-07
@deleted-Ruslan80849

https://regex101.com/r/lH8jR8/2
Top - what to look for (1 parameter)
Bottom - what to replace with (2 parameter)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question