I want to extract this part. But I couldn’t do it well. So I need you to tell me how to do it.
Example)
https://twitter.com/straw_berry0721/status/1596714080345415681?s=20&t=1nIbnSZ2YN2m5KZaOjO5GA
1596714080345415681
https://twitter.com/xxx/status/1595920708323999744
1595920708323999744
・my code (failed)
final result = _controller.text;
t = s.lastIndexOf('status'));
s.substring(t)
2
Answers
One way to get this is parse it to
Uri
and use itspath
like this:or as @MendelG mentions in comment you can go with regex like this:
You could simply extract the last shown number from URLs like https://twitter.com/xxx/status/1595920708323999744 by splitting it to a
List<String>
then take the last element of it, like this:Note: this will return the number as
String
, if you want to get it as anint
number you could use theint.tryParse()
method like this: