正则表达式:用引号替换问号(由于导入错误)

时间:2022-06-03 18:27:03

I need to replace a question-mark ? with a single quote '. However, only when the "?" is between two letters: qu?est-ce que c?est should become qu'est-ce que c'est.

我需要更换问号吗?单引号'。但是,只有当“?”在两个字母之间:qu?est-ce que c?est应该成为qu'est-ce que c'est。

How are you? should remain unchanged.

你好吗?应保持不变。

Additionally, quoted text like this is ?very? nice should become this is 'very' nice

另外,这样引用的文字是?非常?很好,应该成为'非常'好

Hope there is a RegExp expert out there who can help?

希望有一位RegExp专家可以提供帮助吗?

2 个解决方案

#1


1  

You can match this regex:

你可以匹配这个正则表达式:

([a-zA-Z])\?([a-zA-Z])

and replace with:

并替换为:

$1'$2

#2


0  

And Matching

\?([a-zA-Z]+)\?

and replacing with

并替换为

'$1'

solves the additional question.

解决了另外一个问题。

#1


1  

You can match this regex:

你可以匹配这个正则表达式:

([a-zA-Z])\?([a-zA-Z])

and replace with:

并替换为:

$1'$2

#2


0  

And Matching

\?([a-zA-Z]+)\?

and replacing with

并替换为

'$1'

solves the additional question.

解决了另外一个问题。