回答編集履歴
2
少し訂正
test
CHANGED
@@ -46,7 +46,9 @@
|
|
46
46
|
|
47
47
|
Set mc = re.Execute(Target)
|
48
48
|
|
49
|
-
MyStr = re.Replace(Target, String(Len(mc.Item(0)), " "))
|
49
|
+
'MyStr = re.Replace(Target, String(Len(mc.Item(0)), " "))
|
50
|
+
|
51
|
+
MyStr = re.Replace(Target, String(mc.Item(0).Length, " "))
|
50
52
|
|
51
53
|
|
52
54
|
|
1
正規表現版追加
test
CHANGED
@@ -19,3 +19,37 @@
|
|
19
19
|
MyStr = Right(String(Len(Target), " ") & Val(Target), Len(Target))
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
---
|
26
|
+
|
27
|
+
正規表現を使った場合も書いておきます。
|
28
|
+
|
29
|
+
あまり詳しくはないので2段階になってしまいましたが、たぶんこんな感じじゃないかと思います。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```VBA
|
34
|
+
|
35
|
+
Dim re As RegExp
|
36
|
+
|
37
|
+
Dim mc As MatchCollection
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
Target = "0001203"
|
42
|
+
|
43
|
+
Set re = New RegExp
|
44
|
+
|
45
|
+
re.Pattern = "^0*"
|
46
|
+
|
47
|
+
Set mc = re.Execute(Target)
|
48
|
+
|
49
|
+
MyStr = re.Replace(Target, String(Len(mc.Item(0)), " "))
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
Debug.Print MyStr
|
54
|
+
|
55
|
+
```
|