Python 在字符串中隔离某些文本

Python 在字符串中隔离某些文本,python,string,Python,String,我在python中有一个巨大的字符串 b'{\n "timestamp" : HIDDEN,\n "profileId" : "REDACTED",\n "profileName" : "REMOVED",\n "textures" : {\n "SKIN" : {\n "url" : "http://example.com/e

我在python中有一个巨大的字符串

b'{\n "timestamp" : HIDDEN,\n "profileId" : "REDACTED",\n "profileName" : "REMOVED",\n "textures" : {\n "SKIN" : {\n "url" : "http://example.com/example/123example123",\n "metadata" : {\n "model" : "slim"\n }\n }\n }\n}'
我想知道是否有可能分离出
http://example.com/example/123example123
即使每次运行脚本时,
/123example123
部分都发生了更改。

您可以使用regex

重新导入
#URL正则表达式
regexp=r'((http | https)\:\/\/)?[a-zA-Z0-9\/\?\:@-\\\=\\\.]+\.([a-zA-Z]){2,6}([a-zA-Z0-9\&\/\.\:@-\=\\\\\\.]
字符串=”http://example.com/example/123example123"
url=re.search(regexp,string).group()

url变量应该包含您的url,即使它发生更改。

您可能有JSON字符串。使用
json.loads
解析字符串。是否要在不使用“123example123”的情况下从那里提取链接?欢迎使用堆栈溢出,mlghacker xx!请详细说明你迄今为止所做的尝试、采取的方法和遇到的困难。