Symbol | Description | Example Usage | Matches |
---|---|---|---|
i |
Case-insensitive matching. | /hello/i on HELLO |
HELLO |
m |
Multi-line mode (^ and $ for each line). |
/^hello/m on hello\nworld |
hello |
s |
Single-line mode (. matches newline). |
/a.+c/s on a\nbc |
a\nbc |
g |
Global matching (find all matches). | /\w+/g on hello world |
hello , world |
y |
Sticky matching (starts at lastIndex ). |
/hello/y on hello |
hello |
Symbol | Description | Example Usage | Matches |
---|---|---|---|
(?=...) |
Positive lookahead (asserts what follows). | \w+(?=ing) on running |
runn |
(?!...) |
Negative lookahead (asserts what doesn't follow). | \w+(?!ing) on run |
run |
(?<=...) |
Positive lookbehind (asserts what precedes). | (?<=Mr\. )\w+ on Mr. John |
John |
`(? |
Symbol | Description | Example Usage | Matches |
---|---|---|---|
() |
Captures a group. | (ab)+ on ababab |
ababab |
(?:...) |
Non-capturing group. | (?:ab)+ on ababab |
ababab without capturing |
(?<name>...) |
Named capturing group. The name can be used within the match. | (?<word>\w+) on hello |
hello and names the group word |
\1 , \2 |
Backreference to a group. | (a)(b)\1 on aba |
aba |
Symbol | Description | Example Usage | Matches |
---|---|---|---|
* |
0 or more occurrences. |
a* on aaab |
aaa |
+ |
1 or more occurrences. |
a+ on aaab |
aaa |
? |
0 or 1 occurrence. |
a? on aaab |
a , a , a |
{n} |
Exactly n occurrences. |
a{2} on aaa |
aa |
{n,} |
n or more occurrences. |
a{2,} on aaa |
aaa |
{n,m} |
Between n and m occurrences. |
a{2,3} on aaa |
aa , a |
Symbol | Description | Example Usage | Matches |
---|---|---|---|
^ |
Start of a string. | ^a\d on a1 a2 a3 |
a1 |
$ |
End of a string. | a\d$ on a1 a2 a3 |
a3 |
\b |
Word boundary. | \bword\b on wordplay |
word only |
\B |
Non-word boundary. | \Bword\B on password |
word within password |
Symbol | Description | Example Usage | Matches |
---|---|---|---|
. |
Character except newline (\n ). |
a.b on aab, acb |
aab , acb |
\d |
Digit (0-9). | \d+ on abc123 |
123 |
\D |
Non-digit character. | \D+ on abc123 |
abc! |
\w |
Word character (alphanumeric + _ ). |
\w+ on _hello123!@ |
_hello123 |
\W |
Non-word character. | \W+ on abc!@#123 |
!@# |
\s |
Whitespace character. | \s+ on hello world |
Space between hello and world |
\S |
Non-whitespace character. | \S+ on hello world |
hello , world |
This file contains hidden or 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
fun showExternalAppPicker(context: Context, uri: Uri) { | |
val intent = Intent(Intent.ACTION_VIEW, uri) | |
// Get all matching apps | |
val matchingExternalApps = context.packageManager.queryIntentActivities( | |
intent, | |
PackageManager.MATCH_DEFAULT_ONLY, | |
) | |
displayExternalApps(context, matchingExternalApps) | |
} |
This file contains hidden or 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
val geoUrl = "geo:37.7749,-122.4194" | |
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(geoUrl)) | |
context.startActivity(intent) |
This file contains hidden or 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
fun openExternalApp(context: Context, uri: Uri) { | |
val intent = Intent(Intent.ACTION_VIEW, uri) | |
context.startActivity(intent) | |
} |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<!-- Add this only if you're working with http and use it only in debug builds --> | |
<application | |
android:usesCleartextTraffic="true"> | |
... |
NewerOlder