java 正则 尖括号,带尖括号的正则表达式行为

java 正则 尖括号,带尖括号的正则表达式行为Pleaseexplai toutputanyth echo egrep butthefollow echo egrep Thebehaviour

java 正则 尖括号,带尖括号的正则表达式行为

Please explain to me why the following expression doesn’t output anything:

echo “” | egrep “”

but the following does:

echo “” | egrep “\”

The behaviour of the first is as expected but the second should not output. Is the “\

解决方案

AS @hwnd said \< matches the begining of the word. ie a word boundary \b must exists before the starting word character(character after \< in the input must be a word character),

In your example,

echo “” | egrep “”

In the above example, egrep checks for a literal < character present before the lastname string. But there isn't, so it prints nothing.

$ echo “” | egrep “\”

But in this example, a word boundary \b exists before lastname string so it prints the matched characters.

Some more examples:

$ echo “” | egrep “\

$ echo “” | egrep “\

$ echo “” | egrep “\

$ echo “” | egrep “\”

$ echo “” | egrep “\

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/229576.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月16日 下午4:23
下一篇 2026年3月16日 下午4:24


相关推荐

  • Java详解:淘宝秒杀脚本java

    Java详解:淘宝秒杀脚本java造成雪崩的真实场景1.4.1服务提供者不可用硬件故障:如网络故障、硬盘损坏等。程序的bug:如算法需要占用大量CPU的计算时间导致CPU使用率过高。缓存击穿:比如应用刚重启,短时间内缓存是失效的,导致大量请求直接访问到了数据库,数据库不堪重负,服务不可用。秒杀和大促:服务短时间承载不了那么多请求量。1.4.2重试加大流量用户连续重试:比如用户看到界面上没有响应,所以又操作了一遍,结果又增加了一倍请求量。程序重试机制:比如代码中有多次重试的逻辑,一次失

    2022年6月1日
    37
  • linux查看设备网卡型号,linux查看网卡型号

    linux查看设备网卡型号,linux查看网卡型号linux 显示网卡型号 kudzuprobecl network 范例 root localhost kudzuprobecl network class NETWORKbus PCIdetached 0device eth0driver r8169desc RealtekSemic Ltd RTL8101E

    2026年3月18日
    1
  • Windows本地部署龙虾OpenClaw完整教程

    Windows本地部署龙虾OpenClaw完整教程

    2026年3月14日
    2
  • matlab中wavedec2,Matlab中wavedec使用學習及詳解 | 学步园

    matlab中wavedec2,Matlab中wavedec使用學習及詳解 | 学步园最近在使用對ECG訊號進行小波係數的提取,所以用到了wavedec這個matlab中内置函數。然後盡心學習,發現還挺高深,不是我學到的衹是一點皮毛,因爲要對一段波形進行特徵提取,所以我要看哪個小波係數最能代表波形特徵,然後進行保留。我使用的是:[C,L]=WAVEDEC(X,N,’wname’)這個會返回信號X在levelN(小波分解級數)的小波分解係數。輸出爲兩部分,第一部分C爲小波分解係…

    2022年7月23日
    13
  • 树莓派连接wifi个人热点和远程windows远程登录

    树莓派连接wifi个人热点和远程windows远程登录1.安装完系统后在该目录下新建wpa_supplicant.conf文件填入以下信息country=CNctrl_interface=DIR=/var/run/wpa_supplicantGROUP=netdevupdate_config=1network={ssid="WiFi-A"psk="12345678"key_mgmt=WPA-PSKpriority=1}…

    2022年5月5日
    81
  • Hadoop生态圈python + mapreduce + wordcount

    Hadoop生态圈python + mapreduce + wordcountHadoop生态圈python+mapreduce+wordcount启动hadoop进度发布文件hdfsdfs-put/home/hadoop/hadoop/input/user/hadoop/input查看hdfs现在有一些文件[hadoop@master0hadoop]$hdfsdfs-ls/Found1itemsdrwxr-xr-x-hadoopsupergroup02019-12-0402

    2022年5月21日
    46

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号