我想要一个正则表达式规则 :两个字符中间可以是任何一个字符

来源:百度知道 编辑:UC知道 时间:2024/05/22 05:46:00
比如:我想过滤一些违禁词

如办证,办-证,办|证
就是 含有办证字眼,并且不管中间多一个什么字符都算是违禁词语
不知有没有这种正则表达式呢

[办](\w+)[证]

vb.net

Option Strict Off
Option Explicit On

Namespace Regulator

Public Class RegularExpression

Private Sub Test()
Dim regex As String = "([办])(\w+)([证])"
Dim options As System.Text.RegularExpressions.RegexOptions = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace Or System.Text.RegularExpressions.RegexOptions.Multiline) _
Or System.Text.RegularExpressions.RegexOptions.IgnoreCase)
Dim reg As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(regex, options)
End Sub
End Class
End Namespace

c#
namespace Regulator
{

public class RegularExpression
{

private void Test()
{
string regex = "([办])(\\w+)([证])";