1+2*3-(5/6)+sin(45)-ln(100)

1个回答

import re
import math
s = '1+2*3-(5/6)+sin(45)-ln(100)'
str_sin = re.search('sin(\d+)', s).group()
num_sin = re.search('\d+', str_sin).group()
re_sin = math.sin(int(num_sin))
s = re.sub('sin(\d+)',str(re_sin) ,s,1)
print(s)

python 正则表达式替换的问题 re.sub

[code="java"] {"name":"zhangsan","id":1042732,"type":"2","status":0,"password":"123456789"} [/code] 如何把其中的type 键值替换成空 我需要一个 [code="java"] {"name":"zhangsan","id":1042732,"status":0,"password":"123456789"} [/code] 求一个正则表达式 匹配"type":"2",

python正则表达式 2个及以上字符要放在一起重复 如何表示？

python正则表达式匹配反斜杠

java怎么样将字符串中重复的字符替换成单个字符的正则表达式

python正则替换某2个字符串中任意字符串

Python 如何用正则表达式只保留字符串中汉字和换行符？

python中用正则表达式去掉除汉字以外的所有字符

``` 文本如下： gallery: JSON.parse("{\"count\":9,\"sub_images\":[{\"url\":\"http:\\/\\/p99.pstatp.com\\/origin\\/pgc-image\\/15371927302561aa0dfe478\",\"width\":960,\"url_list\":[{\"url\":\"http:\\/\\/p99.pstatp.com\\/origin\\/pgc-image\\/15371927302561aa0dfe478\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/pgc-image\\/15371927302561aa0dfe478\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/pgc-image\\/15371927302561aa0dfe478\"}],\"uri\":\"origin\\/pgc-image\\/15371927302561aa0dfe478\",\"height\":1708},{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/pgc-image\\/1537192730202e35711ae11\",\"width\":960,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/pgc-image\\/1537192730202e35711ae11\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/pgc-image\\/1537192730202e35711ae11\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/pgc-image\\/1537192730202e35711ae11\"}],\"uri\":\"origin\\/pgc-image\\/1537192730202e35711ae11\",\"height\":1707},{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/pgc-image\\/1537192730659330a96f759\",\"width\":960,\"url_list\":[{\"url\":\"http:\\/\\/p1.pstatp.com\\/origin\\/pgc-image\\/1537192730659330a96f759\"},{\"url\":\"http:\\/\\/pb3.pstatp.com\\/origin\\/pgc-image\\/1537192730659330a96f759\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/pgc-image\\/1537192730659330a96f759\"}],\"uri\":\"origin\\/pgc-image\\/1537192730659330a96f759\",\"height\":1709},{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/pgc-image\\/15371927312522155d2679a\",\"width\":960,\"url_list\":[{\"url\":\"http:\\/\\/p3.pstatp.com\\/origin\\/pgc-image\\/15371927312522155d2679a\"},{\"url\":\"http:\\/\\/pb9.pstatp.com\\/origin\\/pgc-image\\/15371927312522155d2679a\"},{\"url\":\"http:\\/\\/pb1.pstatp.com\\/origin\\/pgc-image\\/15371927312522155d2679a\"}],\"uri\":\"origin\\/pgc-image\ ``` 需要匹配内容是： ``` http:\\/\\/p99.pstatp.com\\/origin\\/pgc-image\\/15371927302561aa0dfe478 ```

Golang如何用正则表达式组替换字符串？ [重复]

<div class="post-text" itemprop="text"> <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/37274282/regex-with-replace-in-golang" dir="ltr">Regex with replace in Golang</a> <span class="question-originals-answer-count"> 1 answer </span> </li> </ul> </div> <p>I want to use regex group to replace string in <code>golang</code>, just like as follow in <code>python</code>:</p> <pre><code>re.sub(r"(\d.*?)[a-z]+(\d.*?)", r"\1 \2", "123abc123") # python code </code></pre> <p>So how do I implement this in golang?</p> </div>

java如何将字符串的所有括号中指定字符替换掉？（正则表达式或者其它方法）

python re正则表达式，怎么匹配一段字符中间 的部分，已知头尾

springboot+jwt实现token登陆权限认证

MySQL数据库面试题（2020最新版）

2020阿里全球数学大赛：3万名高手、4道题、2天2夜未交卷

HashMap底层实现原理，红黑树，B+树，B树的结构原理 Spring的AOP和IOC是什么？它们常见的使用场景有哪些？Spring事务，事务的属性，传播行为，数据库隔离级别 Spring和SpringMVC，MyBatis以及SpringBoot的注解分别有哪些？SpringMVC的工作原理，SpringBoot框架的优点，MyBatis框架的优点 SpringCould组件有哪些，他们...

Python爬虫，高清美图我全都要（彼岸桌面壁纸）

Java岗开发3年，公司临时抽查算法，离职后这几题我记一辈子