Last active
December 22, 2019 14:51
-
-
Save Blasanka/3d547fa15849f9794b7dbb8627499b00 to your computer and use it in GitHub Desktop.
Regular expression to find urls in String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final text = """My website url: https://blasanka.github.io/ | |
Google search using: www.google.com, social media is facebook.com, http://example.com/method?param=flutter | |
stackoverflow.com is my greatest website. DartPad share: https://github.com/dart-lang/dart-pad/wiki/Sharing-Guide see this example and edit it here """; | |
RegExp exp = new RegExp(r'(?:(?:https?|ftp):\/\/)?[\w/\-?=%.]+\.[\w/\-?=%.]+'); | |
Iterable<RegExpMatch> matches = exp.allMatches(text); | |
matches.forEach((match) { | |
print(text.substring(match.start, match.end)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment