Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex PL SQL模式匹配_Regex_Oracle_Regex Negation - Fatal编程技术网

Regex PL SQL模式匹配

Regex PL SQL模式匹配,regex,oracle,regex-negation,Regex,Oracle,Regex Negation,如果某个单词(例如test)真的是“行开始+可选空格+test+空格”,那么如何仅从大字符串中解释该单词(例如test)。还允许单词“test”大小写混合使用REGEXP\u替换为所有参数,您可以 提供要影响的值 提供要查找的正则表达式 告诉函数从哪个字符开始 告诉函数要替换的事件 提供额外的修饰符,其中“i”表示用例不敏感 如果您希望删除第二个test实例,或test,或test,这将起作用。您没有提供太多示例和预期结果 -- Start test data with test_data as

如果某个单词(例如test)真的是“行开始+可选空格+test+空格”,那么如何仅从大字符串中解释该单词(例如test)。还允许单词“test”大小写混合使用REGEXP\u替换为所有参数,您可以

  • 提供要影响的值
  • 提供要查找的正则表达式
  • 告诉函数从哪个字符开始
  • 告诉函数要替换的事件
  • 提供额外的修饰符,其中“i”表示用例不敏感
  • 如果您希望删除第二个test实例,或test,或test,这将起作用。您没有提供太多示例和预期结果

    -- Start test data
    with test_data as
        (select 'TeSt this is how I am going to tEst going for' as test_string from dual union all
         select 'test hello everyone how are you test' from dual union all
         select 'test_find1();' from dual union all
         select 'test sample 1;' from dual union all
         select 'TEST sample 2;' from dual union all
         select 'test1 hope this is will help test2;' from dual)
    -- End test data     
    select test_string,
           CASE WHEN REGEXP_LIKE(test_string,'^test\s+','i') THEN
                        REGEXP_REPLACE(test_string,'test','', 1, 2, 'i')
               ELSE NULL END AS result
    from   test_data;
    

    关于REGEXP_REPLACE的更多信息

    我正在使用您的输入字符串,如下所示

    '    TeSt this is how I am going to tEst going for '
    
    故意在开头和结尾保留一些空白。下面的代码生成所需的输出。正如您所提到的,它将替换单词TEST的所有实例,而不考虑大小写。 我希望这有帮助

      Select 
    REGEXP_REPLACE(     --Using RegExp_replace
        ltrim(rtrim(    --Trimming the white spaces
            input1)),   --using the input
            'TEST',     --search criteria
            '',         --Replace with string
            2,          --Starting with which character (you mentioned first occerance should remain
            0,          --Replace all subsequent occurances
            'i')        --case in-sensitive
            from (
    Select '    TeSt this is how I am going to tEst going for' as input1 from dual --this is your INPUT)
    
    谢谢,
    桑托什

    你所说的“解释”一个词是什么意思?这不是SQL或数据库的概念。我的意思是匹配单词test,它必须是行的开头+可选空格+test+空格“match”也不清楚。看起来您正在读取输入字符串,必须输出它们,要么保持不变,要么进行一些更改。似乎必须删除单词
    test
    ,除非它是第一个单词?如果单词
    test
    ,不是在字符串的开头,而是在字符串的后面,后跟逗号或句点,而不是空格,该怎么办?如果它在字符串的末尾呢?如果字符串不是以单词
    test
    开头,该怎么办?是否仍需要在其他地方删除它?对于计算机和软件,您需要一个100%明确的问题要求,不应让任何人猜测。例如:“测试这是我将如何测试”我希望此输出是:“测试这是我将如何测试”@mathguy付出了巨大的努力,但请回顾一下,谢谢,但是上面的示例没有处理行首+可选空格和测试后的强制空格如果我们只想在行首出现单词“test”时保留字符串的整行,应该怎么做?如果它出现在任何地方,则整行应该删除