regex

Replace $x<y$ by $x < y$

左心房为你撑大大i 提交于 2021-02-20 11:24:56
问题 I want to search in text for the less than sign < between dollar signs like $x<y$ and replace it by $x < y$ . I am using mathjax and less than sign causes some problems in rendering Mathjax.(See here: http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents). I tried $text = preg_replace("/\$(.*?)(<)(.*?)\$/","/\$$1 < $3\$/",$text) but I am not sure if this is a good solution. I am new to programming:) Thank you for your help. 回答1: I edited my previous answer - now try this:

find命令详解

空扰寡人 提交于 2021-02-20 08:28:40
find命令是一种实时查找工具,通过遍历指定的路径完成文件查找 工作特点:   由于是遍历指定路径,所以相对locate而言,它的查找速度略慢   精确查找,与locate不同的是,find是遍历指定路径,而不是通过数据库查找   实时查找,不需要向locate一样,定期更新数据库   在查找的同时,只能搜索到用户具备读取和执行权限的文件 语法: find [option]……[查找路径] [查找条件] [处理动作]   查找路径:指定具体路径;默认为当前目录   查找条件:指定的查找标准,可以文件名、大小、类型、权限等标准进行,默认为找出指定路径下的所有文件   处理动作:对符合条件的文件做操作,默认输出到屏幕 查找条件可以分为以下几类: 一、按搜索层级进行搜索 选项:-maxdepth level  #最大搜索目录深度    -mindepth level  #最小搜索目录深度 举例:搜索ifcfg-ens33 上图中,当没有加maxdepth层级选项时,默认将所有的同名的文件路径输出到了屏幕。 由于上图中指定以/为路径查找,所以/的文件为第一级,而/root/ifcfg-en33则为第二级,/etc/sysconfig/network-scripts/ifcfg-ens33则为第四级 二、通过文件名查找文件 -name “文件名称”  #通过文件名查找文件,支持通配符 举例

Raku regex: How to use capturing group inside lookaheads

落爺英雄遲暮 提交于 2021-02-20 06:32:30
问题 How can I use capturing groups inside lookahead assertion? This code: say "ab" ~~ m/(a) <?before (b) > /; returns: 「a」 0 => 「a」 But I was expecting to also capture 'b'. Is there a way to do so? I don't want to leave 'b' outside of the lookahead because I don't want 'b' to be part of the match. Is there a way to capture 'b' but still leave it outside of the match? NOTE: I tried to use Raku's capture markers, as in: say "ab" ~~ m/<((a))> (b) /; 「a」 0 => 「a」 1 => 「b」 But this does not seem to

Raku regex: How to use capturing group inside lookaheads

随声附和 提交于 2021-02-20 06:32:14
问题 How can I use capturing groups inside lookahead assertion? This code: say "ab" ~~ m/(a) <?before (b) > /; returns: 「a」 0 => 「a」 But I was expecting to also capture 'b'. Is there a way to do so? I don't want to leave 'b' outside of the lookahead because I don't want 'b' to be part of the match. Is there a way to capture 'b' but still leave it outside of the match? NOTE: I tried to use Raku's capture markers, as in: say "ab" ~~ m/<((a))> (b) /; 「a」 0 => 「a」 1 => 「b」 But this does not seem to

Raku regex: How to use capturing group inside lookaheads

一世执手 提交于 2021-02-20 06:29:33
问题 How can I use capturing groups inside lookahead assertion? This code: say "ab" ~~ m/(a) <?before (b) > /; returns: 「a」 0 => 「a」 But I was expecting to also capture 'b'. Is there a way to do so? I don't want to leave 'b' outside of the lookahead because I don't want 'b' to be part of the match. Is there a way to capture 'b' but still leave it outside of the match? NOTE: I tried to use Raku's capture markers, as in: say "ab" ~~ m/<((a))> (b) /; 「a」 0 => 「a」 1 => 「b」 But this does not seem to

How to parse a regular expression?

早过忘川 提交于 2021-02-20 05:29:26
问题 Disclaimer before this is auto-closed. This is NOT the same as this: How do you access the matched groups in a JavaScript regular expression? Let's say I have this regular expression: const regex = /(\w+) count: (\d+)/ Is there a way I can extract the capture groups so that I have: [ '\w+', '\d+' ]` 回答1: As others pointed out you'd need a real parser, such as Lex & Yacc. You can however use regex and some recursion magic to parse nested structures. See details at https://twiki.org/cgi-bin

How to replace all string between second and third occurance of pipe character using regex?

杀马特。学长 韩版系。学妹 提交于 2021-02-20 05:28:05
问题 I would like to replace all the characters occurring between second and third pipe character. Example: |hello|welcome,to| In this I want replace welcome,to with a blank value, with a huge file to be replaced. I need a regex pattern to be used in notepad++. 回答1: Assuming you're parsing each line, i.e. a token cannot include a newline: Find what: ^((?:[^|\n]*\|){2})[^|\n]*+\| Replace with: $1| Description ^ - matches the start of line ((?:[^|\n]*\|){2}) - matches and captures in group 1: (?:[^|

redirect urls from specific folder to external domains (with php?)

爷,独闯天下 提交于 2021-02-20 04:36:05
问题 The site i need this for is a wordpress site, Basicly my /out/ folder is followed by an url of a partner. i want people that go to such a link to get forwarded to that url I know there are plugins to do this manual, but i will need thousands of urls, so i basicly want to do it with a wildcard somehow Is this possible to do with php? https://example.com/out/https://externaldomain.com should go to https:// externaldomain.com this part will change, but is always an url: https://example.com/out/*

Regex to match any number after certain strings

倾然丶 夕夏残阳落幕 提交于 2021-02-20 04:28:05
问题 I want to match the userid number in a url string that's usually after a id= or /user/ Examples: http://dummy.url/url/path/id=7623 http://dummy.url/url/path/user/8743 http://dummy.url/url/path/user/56 http://dummy.url/url/path=88772/user/890&more=87273&variables&here=76233 http://dummy.url/url/path/id=2818372 I need to match 7623, 8743, 56, 890, 2818372 I haven't tried much on this as I'm a complete noob at regex and I only know how to mach numbers, all numbers, so if the url has any it will

how do you extract the columns that contain a certain text/string in R

点点圈 提交于 2021-02-20 04:17:25
问题 I need to be able to extract columns that contain exact string that I am looking for. For example, I have this data frame x: structure(list(Time = structure(1L, .Label = "1/1/2015", class = "factor"), WTAD..Linux..Linux.Percent.of.Physical.Memory.and.Swap.Used.on.web02.Total.Phys.Mem.MB. = 3555L, WTAD..Linux..Linux.Percent.of.Physical.Memory.and.Swap.Used.on.web02.Total.Phys.Mem.Free.MB. = 55L, WTAD..Linux..Linux.Percent.of.Physical.Memory.and.Swap.Used.on.web02.Total.Swap.Free.MB. = 44L,