如何找到"小写字符的第一个实例"在Excel中使用VBA的单元格中? 我尝试过使用ASCII值但是没有用。
答案 0 :(得分:0)
RegExp
另一个Microsoft VBScript Regular Expressions 1.0
解决方案,需要添加VBA
(在Tools->Referances
窗口,Private Function DeleteLowerCasesRegExp(InputString As String)
Dim RE As New RegExp
With RE
.Global = True
.IgnoreCase = False
.Pattern = "[a-z]"
DeleteLowerCasesRegExp = .Replace(InputString, "")
End With
End Function
菜单中)
Like
使用另一种解决方案,RegExp
也不使用Private Function DeleteLowerCasesAsc(InputString As String) As String
Dim i As Integer
For i = 1 To Len(InputString)
If Mid(InputString, i, 1) = Empty Then Exit For
If Asc(Mid(InputString, i, 1)) >= 97 And Asc(Mid(InputString, i, 1)) <= 122 Then
InputString = Left(InputString, i - 1) & Mid(InputString, i + 1)
i = i - 1
End If
Next
DeleteLowerCasesAsc = InputString
End Function
:
replace
使用Private Function DeleteLowerCasesReplace(InputString As String) As String
Dim i As Integer
For i = 97 To 122
InputString = Replace(InputString, Chr(i), "")
Next
DeleteLowerCasesReplace = InputString
End Function
函数的另一种解决方案:
<?php
use GuzzleHttp\Client;
require 'vendor/autoload.php';
$url = "http://jsonplaceholder.typicode.com/posts";
$client = new Client();
$body['title'] = "json guzzle post";
$body['body'] = "carlton";
$body['userId'] = "109109101";
$res = $client->post($url, [ 'body' => json_encode($body) ]);
$code = $res->getStatusCode();
$result = $res->json();
var_dump($code);
var_dump($result);
答案 1 :(得分:0)
尝试以下小型 UDF:
Public Function Findlower(rin As Range) As Long
Dim v As String, CH As String, i As Long
Findlower = 0
v = rin.Text
L = Len(v)
For i = 1 To L
If Mid(v, i, 1) Like "[a-z]" Then
Findlower = i
Exit Function
End If
Next i
End Function
它将以字符串形式返回任何小写字母的第一个实例的位置:
答案 2 :(得分:0)
您可以在UDF中使用RegExp
来避免遍历每个字符:
Function FirstLower(strIn As String) as String
Dim objRegex As Object
Dim objRegM As Object
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
.Pattern = "[a-z]"
.ignorecase = False
If .test(strIn) Then
Set objRegM = .Execute(strIn)(0)
FirstLower = objRegM.firstindex + 1
Else
FirstLower = "no match"
End If
End With
End Function