我一直在研究这样的正则表达式,我需要检查字符串,使其至少包含 3 个大写字母和至少 3 个数字,术语不应包含特殊。字符,即字符串中只能包含大写字母、数字和小写字母。也许有人知道如何编写这样的正则表达式?)
- aaaaaSaaSasAd212D - 有效
- gfg1fdgdSSSdsad3f3 - 有效
- dfsdfsfdf3fsdfsfF - 无效
我一直在研究这样的正则表达式,我需要检查字符串,使其至少包含 3 个大写字母和至少 3 个数字,术语不应包含特殊。字符,即字符串中只能包含大写字母、数字和小写字母。也许有人知道如何编写这样的正则表达式?)
面对这样的问题,无法向服务器发送http请求。抛出错误“未指定网络安全配置,使用平台默认值”。我将 android:usesCleartextTraffic="true" 添加到清单中,但没有帮助。对于发送,我使用 Khttp 库。也许有人遇到过类似的问题。
override fun getToken(email: String, password: String) {
val client = OkHttpClient()
val formBody = FormBody.Builder()
.add("email", "artur.yashchenko@nure.ua")
.add("password", "123123")
.build()
val request = Request.Builder()
.url("http://192.168.0.101:8080/login")
.post(formBody)
.build()
try {
val response = client.newCall(request).execute()
print(response.body)
// Do something with the response.
} catch (e: IOException) {
e.printStackTrace()
}
}
<?xml version="1.0" encoding="utf-8"?>
<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activities.ProfileActivity"></activity>
<activity android:name=".activities.CreateOrderActivity" />
<activity android:name=".activities.InnerOrderActivity" />
<activity android:name=".activities.MyOrdersActivity">
</activity>
<activity android:name=".activities.SignUpActivity" />
<activity android:name=".activities.MenuActivity">
</activity>
<activity android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ua.nure.gms, PID: 5377
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1565)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:389)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
at java.net.Socket.connect(Socket.java:621)
at okhttp3.internal.platform.AndroidPlatform.connectSocket(AndroidPlatform.kt:58)
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:268)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:176)
at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:236)
at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:109)
at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:77)
at okhttp3.internal.connection.Transmitter.newExchange$okhttp(Transmitter.kt:162)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:35)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
at okhttp3.RealCall.execute(RealCall.kt:66)
at ua.nure.gms.repositories.impl.AuthenticationRepositoryImpl.getToken(AuthenticationRepositoryImpl.kt:30)
at ua.nure.gms.activities.MainActivity$onCreate$1.onClick(MainActivity.kt:19)
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27336)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
面对这样的问题,“????” 而不是西里尔字母。我将项目设置更改为编码UTF-8
,也更改了MySQL数据库UTF-8
,我不知道该尝试什么。有人能遇到吗?