|
wyd531
初级用户
  菜鸟
积分 137
发帖 49
注册 2006-12-20
状态 离线
|
『楼 主』:
截取文本字符
使用 LLM 解释/回答一下
1.txt
Microsoft\Updates\Windows Media Player\KB832353
Microsoft\Updates\Windows Media Services\KB822343
Microsoft\Updates\Windows Media Services\KB832359
怎样截取KB832353这段字符,
To intercept the character "KB832353" in the following paths:
First path: "Microsoft\Updates\Windows Media Player\KB832353"
The part after the last backslash "\" is "KB832353", so you can use string manipulation methods to get the substring starting from the last backslash.
Second path: "Microsoft\Updates\Windows Media Services\KB832359"
Here the relevant part is not "KB832353".
The specific way to intercept depends on the programming language you are using. For example, in Python:
For the first path string, you can do:
path = r"Microsoft\Updates\Windows Media Player\KB832353"
start_index = path.rfind("\\") + 1
kb_number = path
print(kb_number)
This will extract "KB832353" from the first path.
In Java:
String path = "Microsoft\\Updates\\Windows Media Player\\KB832353";
int lastBackslashIndex = path.lastIndexOf("\\");
String kbNumber = path.substring(lastBackslashIndex + 1);
System.out.println(kbNumber);
So the intercepted character "KB832353" can be obtained through such string operation methods.
|

我是一只小菜鸟,依呀依呀哟~~~ |
|
2007-1-13 00:34 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
|
2007-1-13 00:48 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
@echo off
for /f "delims=" %%a in (1.txt) do (
Setlocal EnableDelayedExpansion
set a=%%a
set a=!a: =!
echo !a:~-8!
Endlocal
)
pause
@echo off
for /f "delims=" %%a in (1.txt) do (
Setlocal EnableDelayedExpansion
set a=%%a
set a=!a: =!
echo !a:~-8!
Endlocal
)
pause
|
|
2007-1-13 00:57 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
利用 for 扩展,来个更简洁的代码:
@echo off
for /f "delims=" %%i in (1.txt) do echo "%%~nxi"
pause
Using for extension, make a more concise code:
@echo off
for /f "delims=" %%i in (1.txt) do echo "%%~nxi"
pause
此帖被 +7 点积分 点击查看详情 评分人:【 lxmxn 】 | 分数: +2 | 时间:2007-1-14 05:57 | 评分人:【 redtek 】 | 分数: +5 | 时间:2007-2-3 21:36 |
|
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2007-1-13 22:47 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
斑竹的思路很好啊,要想只显示KB832353还要改动一下。
The idea of the moderator is very good. If you want to only display KB832353, you need to make some changes.
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-1-13 23:13 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
|
2007-1-14 03:04 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
|
2007-1-14 05:58 |
|
|
applecy
初级用户
 
积分 168
发帖 78
注册 2006-12-27
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
4楼的方法好``不过要是我要提取的是中间的部分呢?
"Microsoft\Updates\Windows Media Player\KB832353" 中的
"Windows Media Player"呢?
The method of the 4th floor is good. But if I want to extract the middle part, how about "Windows Media Player" in "Microsoft\Updates\Windows Media Player\KB832353"?
|
|
2007-1-14 08:30 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
|
2007-1-14 08:52 |
|
|
applecy
初级用户
 
积分 168
发帖 78
注册 2006-12-27
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
呵呵`谢谢了`还在消化中.
想提个小建议,不知道能否开个收藏功能呢`?毕竟有很多新手不能一时完全掌握,而想查的时候又很难找到指定的帖子,有收藏功能之后一切就更简便了
Hehe, thanks. Still digesting.
I want to make a small suggestion. I wonder if a bookmarking function can be added? After all, many newbies can't fully grasp everything at once, and it's difficult to find the specified post when they want to check it. With the bookmarking function, everything will be more convenient.
|
|
2007-1-15 09:14 |
|
|
zjindong
初级用户
 
积分 64
发帖 26
注册 2006-1-10
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
有收藏啊.网页最下面就有了
There are collections. It's at the bottom of the web page.
|
|
2007-2-3 14:55 |
|
|
amao
中级用户
  
积分 316
发帖 152
注册 2006-6-18
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
@sed "s/ *$//;s/.*\\\(.*\)/\1/" 1.txt
@sed "s/ *$//;s/.*\\\(.*\)/\1/" 1.txt
|
|
2007-2-3 16:05 |
|
|
amao
中级用户
  
积分 316
发帖 152
注册 2006-6-18
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
Originally posted by applecy at 2007-1-14 08:30:
4楼的方法好``不过要是我要提取的是中间的部分呢?
"Microsoft\Updates\Windows Media Player\KB832353" 中的
"Windows Media Player"呢?
@sed "s/.*\\.*\\\(.*\)\\.*/\1/" 1.txt
Originally posted by applecy at 2007-1-14 08:30:
The method on floor 4 is good`` but what if I want to extract the middle part?
What about "Windows Media Player" in "Microsoft\Updates\Windows Media Player\KB832353"?
@sed "s/.*\\.*\\\(.*\)\\.*/\1/" 1.txt
|
|
2007-2-3 16:10 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
又学习了tokens的用法
I've learned about the usage of tokens again
|
|
2007-2-4 00:03 |
|
|
minmin888
初级用户
 
积分 127
发帖 62
注册 2007-4-19
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
一问多解,学到东西!
Solving one question in multiple ways, learning something!
|
|
2007-5-8 13:50 |
|