0

0

shell对文件的操作

雪夜

雪夜

发布时间:2025-07-18 11:22:01

|

749人浏览过

|

来源于php中文网

原创

shell脚本编写中,时常会用到对文件的相关操作,比如增加内容,修改内容,删除部分内容,查看部分内容等,但是上述举例的这些操作一般都是需要在文本编辑器中才能操作,常用的文本编辑器如:gedit、vim、nano等又是交互式文本编辑器,脚本无法自己独立完成,必须有人参与才可以完成。如果这样的话又违背了我们编写脚本的意愿(全部由机器来完成,减少人的工作压力,提升工作效率)。emm…如何才能让这些操作全部脚本自己就搞定,而不需要人的参与,而且又能按照我们的脚本预案来完成呢?

为了解决上述问题,linux为大家提供了一些命令,比如Perl、sed等命令,今天我就着重为大家介绍一下sed命令。

一、sed介绍

sed是linux中提供的一个外部命令,它是一个行(流)编辑器,非交互式的对文件内容进行增删改查的操作,使用者只能在命令行输入编辑命令、指定文件名,然后在屏幕上查看输出。它和文本编辑器有本质的区别。

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">区别是:文本编辑器: 编辑对象是文件行编辑器:编辑对象是文件中的行</code>

也就是前者一次处理一个文本,而后者是一次处理一个文本中的一行。这个是我们应该弄清楚且必须牢记的,否者可能无法理解sed的运行原理和使用精髓。

sed数据处理原理

shell对文件的操作
二、sed语法

sed 命令语法:

sed [options] ‘{command}[flags]’ [filename]

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">#命令选项-e script 将脚本中指定的命令添加到处理输入时执行的命令中  多条件,一行中要有多个操作-f script 将文件中指定的命令添加到处理输入时执行的命令中-n        抑制自动输出-i        编辑文件内容-i.bak    修改时同时创建.bak备份文件。-r        使用扩展的正则表达式!         取反 (跟在模式条件后与shell有所区别)#command   对文件干什么sed常用内部命令a   在匹配后面添加i   在匹配前面添加d   删除s   查找替换  字符串c   更改y   转换   N D P p   打印#flags数字             表示新文本替换的模式g:             表示用新文本替换现有文本的全部实例p:             表示打印原始的内容w filename:     将替换的结果写入文件</code>
2.1)sed内部命令说明

演示实例文档

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">[root@zutuanxue ~]# cat data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.</code>

文件内容增加操作,将数据追加到某个位置之后,使用命令a。

演示案例

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">在data1的每行后追加一行新数据内容: append data "haha"[root@zutuanxue ~]# sed 'a\append data "haha"' data11 the quick brown fox jumps over the lazy dog.append data "haha"2 the quick brown fox jumps over the lazy dog.append data "haha"3 the quick brown fox jumps over the lazy dog.append data "haha"4 the quick brown fox jumps over the lazy dog.append data "haha"5 the quick brown fox jumps over the lazy dog.append data "haha"在第二行后新开一行追加数据: append data "haha"[root@zutuanxue ~]# sed '2a\append data "haha"' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.append data "haha"3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.在第二到四行每行后新开一行追加数据: append data "haha"[root@zutuanxue ~]# sed '2,4a\append data "haha"' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.append data "haha"3 the quick brown fox jumps over the lazy dog.append data "haha"4 the quick brown fox jumps over the lazy dog.append data "haha"5 the quick brown fox jumps over the lazy dog.匹配字符串追加: 找到包含"3 the"的行,在其后新开一行追加内容: append data "haha"[root@zutuanxue ~]# sed '/3 the/a\append data "haha"' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.append data "haha"4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.//开启匹配模式  /要匹配的字符串/</code>

文件内容增加操作,将数据插入到某个位置之前,使用命令i。

演示案例

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">在data1的每行前插入一行新数据内容: insert data "haha"[root@zutuanxue ~]# sed 'i\insert data "haha"' data1insert data "haha"1 the quick brown fox jumps over the lazy dog.insert data "haha"2 the quick brown fox jumps over the lazy dog.insert data "haha"3 the quick brown fox jumps over the lazy dog.insert data "haha"4 the quick brown fox jumps over the lazy dog.insert data "haha"5 the quick brown fox jumps over the lazy dog.在第二行前新开一行插入数据: insert data "haha"[root@zutuanxue ~]# sed '2i\insert data "haha"' data11 the quick brown fox jumps over the lazy dog.insert data "haha"2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.在第二到四行每行前新开一行插入数据: insert data "haha"[root@zutuanxue ~]# sed '2,4i\insert data "haha"' data11 the quick brown fox jumps over the lazy dog.insert data "haha"2 the quick brown fox jumps over the lazy dog.insert data "haha"3 the quick brown fox jumps over the lazy dog.insert data "haha"4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.匹配字符串插入: 找到包含"3 the"的行,在其前新开一行插入内容: insert data "haha"[root@zutuanxue ~]# sed '/3 the/i\insert data "haha"' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.insert data "haha"3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.</code>

文件内容修改操作–替换,将一行中匹配的内容替换为新的数据,使用命令s。

演示案例

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">从标准输出流中做替换,将test替换为text[root@zutuanxue ~]# echo "this is a test" |sed 's/test/text/'this is a text将data1中每行的dog替换为cat[root@zutuanxue ~]# sed 's/dog/cat/' data11 the quick brown fox jumps over the lazy cat.2 the quick brown fox jumps over the lazy cat.3 the quick brown fox jumps over the lazy cat.4 the quick brown fox jumps over the lazy cat.5 the quick brown fox jumps over the lazy cat.将data1中第二行的dog替换为cat[root@zutuanxue ~]# sed '2s/dog/cat/' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy cat.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.将data1中第二到第四行的dog替换为cat[root@zutuanxue ~]# sed '2,4s/dog/cat/' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy cat.3 the quick brown fox jumps over the lazy cat.4 the quick brown fox jumps over the lazy cat.5 the quick brown fox jumps over the lazy dog.匹配字符串替换:将包含字符串"3 the"的行中的dog替换为cat[root@zutuanxue ~]# sed '/3 the/s/dog/cat/' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy cat.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.</code>

文件内容修改操作–更改,将一行中匹配的内容替换为新的数据,使用命令c。

演示案例

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">将data1文件中的所有行的内容更改为: change data "data"[root@zutuanxue ~]# sed 'c\change data "haha"' data1change data "haha"change data "haha"change data "haha"change data "haha"change data "haha"将data1文件第二行的内容更改为: change data "haha"[root@zutuanxue ~]# sed '2c\change data "haha"' data11 the quick brown fox jumps over the lazy dog.change data "haha"3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.将data1文件中的第二、三、四行的内容更改为:change data "haha"[root@zutuanxue ~]# sed '2,4c\change data "haha"' data11 the quick brown fox jumps over the lazy dog.change data "haha"5 the quick brown fox jumps over the lazy dog.将data1文件中包含"3 the"的行内容更改为: change data "haha"[root@zutuanxue ~]# sed '/3 the/c\change data "data"' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.change data "data"4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.</code>

文件内容修改操作–字符转换,将一行中匹配的内容替换为新的数据,使用命令y。

演示案例

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">将data1中的a b c字符转换为对应的 A  B  C字符[root@zutuanxue ~]# sed 'y/abc/ABC/' data11 the quiCk Brown fox jumps over the lAzy dog.2 the quiCk Brown fox jumps over the lAzy dog.3 the quiCk Brown fox jumps over the lAzy dog.4 the quiCk Brown fox jumps over the lAzy dog.5 the quiCk Brown fox jumps over the lAzy dog.</code>

文件内容删除,将文件中的指定数据删除,使用命令d。

演示案例

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">删除文件data1中的所有数据[root@zutuanxue ~]# sed 'd' data1删除文件data1中的第三行数据[root@zutuanxue ~]# sed '3d' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.删除文件data1第三到第四行的数据[root@zutuanxue ~]# sed '3,4d' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.删除文件data1中包含字符串"3 the"的行[root@zutuanxue ~]# sed '/3 the/d' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.</code>

文件内容查看,将文件内容输出到屏幕,使用命令p。

AISEO
AISEO

AI创作对SEO友好的文案和文章

下载

演示案例

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">打印data1文件内容[root@zutuanxue ~]# sed 'p' data11 the quick brown fox jumps over the lazy dog.1 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.打印data1文件第三行的内容[root@zutuanxue ~]# sed '3p' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.打印data1文件第二、三、四行内容[root@zutuanxue ~]# sed '2,4p' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.打印data1文件包含字符串"3 the"的行[root@zutuanxue ~]# sed '/3 the/p' data11 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog. 可以看得出,打印内容是重复的行,原因是打印了指定文件内容一次,又将读入缓存的所有数据打印了一次,所以会看到这样的效果,如果不想看到这样的结果,可以加命令选项-n抑制内存输出即可。</code>
2.2)命令选项说明

sed语法 在sed命令中,命令选项是对sed中的命令的增强

在命令行中使用多个命令 -e

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">将brown替换为green dog替换为cat[root@zutuanxue ~]# sed -e 's/brown/green/;s/dog/cat/' data11 the quick green fox jumps over the lazy cat.2 the quick green fox jumps over the lazy cat.3 the quick green fox jumps over the lazy cat.4 the quick green fox jumps over the lazy cat.5 the quick green fox jumps over the lazy cat.</code>

从文件读取编辑器命令 -f 适用于日常重复执行的场景

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">1)将命令写入文件[root@zutuanxue ~]# vim abcs/brown/green/s/dog/cat/s/fox/elephant/2)使用-f命令选项调用命令文件[root@zutuanxue ~]# sed -f abc data1 1 the quick green elephant jumps over the lazy cat.2 the quick green elephant jumps over the lazy cat.3 the quick green elephant jumps over the lazy cat.4 the quick green elephant jumps over the lazy cat.5 the quick green elephant jumps over the lazy cat.</code>

抑制内存输出 -n

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">打印data1文件的第二行到最后一行内容  $最后的意思[root@zutuanxue ~]# sed -n '2,$p' data1 2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.</code>

使用正则表达式 -r

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">打印data1中以字符串"3 the"开头的行内容[root@zutuanxue ~]# sed -n  -r '/^(3 the)/p' data13 the quick brown fox jumps over the lazy dog.</code>

从上述的演示中,大家可以看出,数据处理只是在缓存中完成的,并没有实际修改文件内容,如果需要修改文件内容可以直接使用-i命令选项。在这里我需要说明的是-i是一个不可逆的操作,一旦修改,如果想复原就很困难,几乎不可能,所以建议大家在操作的时候可以备份一下源文件。-i命令选项提供了备份功能,比如参数使用-i.bak,那么在修改源文件的同时会先备份一个以.bak结尾的源文件,然后再进行修改操作。

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">1)查看文件列表,没有发现data1.bak[root@zutuanxue ~]# lsabc  apache  data1  Dobby  file  node-v10.14.1  Python-3.7.1  soft1  vimset2)执行替换命令并修改文件[root@zutuanxue ~]# sed -i.bak 's/brown/green/' data13)发现文件夹中多了一个data1.bak文件[root@zutuanxue ~]# lsabc     data1      Dobby  node-v10.14.1  soft1apache  data1.bak  file   Python-3.7.1   vimset4)打印比较一下,发现data1已经被修改,data1.bak是源文件的备份。[root@zutuanxue ~]# cat data11 the quick green fox jumps over the lazy dog.2 the quick green fox jumps over the lazy dog.3 the quick green fox jumps over the lazy dog.4 the quick green fox jumps over the lazy dog.5 the quick green fox jumps over the lazy dog.[root@zutuanxue ~]# cat data1.bak 1 the quick brown fox jumps over the lazy dog.2 the quick brown fox jumps over the lazy dog.3 the quick brown fox jumps over the lazy dog.4 the quick brown fox jumps over the lazy dog.5 the quick brown fox jumps over the lazy dog.</code>
2.3)标志

在sed命令中,标志是对sed中的内部命令做补充说明

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">演示文档[root@zutuanxue ~]# cat data21 the quick brown fox jumps over the lazy dog . dog2 the quick brown fox jumps over the lazy dog . dog3 the quick brown fox jumps over the lazy dog . dog4 the quick brown fox jumps over the lazy dog . dog5 the quick brown fox jumps over the lazy dog . dog</code>

数字标志:此标志是一个非零正数,默认情况下,执行替换的时候,如果一行中有多个符合的字符串,如果没有标志位定义,那么只会替换第一个字符串,其他的就被忽略掉了,为了能精确替换,可以使用数字位做定义。

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">替换一行中的第二处dog为cat[root@zutuanxue ~]# sed 's/dog/cat/2' data21 the quick brown fox jumps over the lazy dog . cat2 the quick brown fox jumps over the lazy dog . cat3 the quick brown fox jumps over the lazy dog . cat4 the quick brown fox jumps over the lazy dog . cat5 the quick brown fox jumps over the lazy dog . cat</code>

g标志:将一行中的所有符合的字符串全部执行替换

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">将data1文件中的所有dog替换为cat[root@zutuanxue ~]# sed 's/dog/cat/g' data21 the quick brown fox jumps over the lazy cat . cat2 the quick brown fox jumps over the lazy cat . cat3 the quick brown fox jumps over the lazy cat . cat4 the quick brown fox jumps over the lazy cat . cat5 the quick brown fox jumps over the lazy cat . cat</code>

p标志:打印文本内容,类似于-p命令选项

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">[root@zutuanxue ~]# sed  '3s/dog/cat/p' data21 the quick brown fox jumps over the lazy dog . dog2 the quick brown fox jumps over the lazy dog . dog3 the quick brown fox jumps over the lazy cat . dog3 the quick brown fox jumps over the lazy cat . dog4 the quick brown fox jumps over the lazy dog . dog5 the quick brown fox jumps over the lazy dog . dog</code>

w filename标志:将修改的内容存入filename文件中

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">[root@zutuanxue ~]# sed  '3s/dog/cat/w text' data21 the quick brown fox jumps over the lazy dog . dog2 the quick brown fox jumps over the lazy dog . dog3 the quick brown fox jumps over the lazy cat . dog4 the quick brown fox jumps over the lazy dog . dog5 the quick brown fox jumps over the lazy dog . dog可以看出,将修改的第三行内容存在了text文件中[root@zutuanxue ~]# cat text 3 the quick brown fox jumps over the lazy cat . dog</code>
三、练习案例

3.1、写一个初始化系统的脚本 案例需求 1)自动修改主机名(如:ip是192.168.0.88,则主机名改为server88.zutuanxue.cc)

a. 更改文件非交互式 sed

/etc/sysconfig/network

b.将本主机的IP截取出来赋值给一个变量ip;再然后将ip变量里以.分割的最后一位赋值给另一个变量ip1

2)自动配置可用的yum源

3)自动关闭防火墙和selinux

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">1、关闭防火墙2、关闭selinux3、配置yum源4、ntp时间服务器 5、更新系统软件包</code>

3.2、写一个搭建ftp服务的脚本,要求如下: 案例需求 1)不支持本地用户登录local_enable=NO 2) 匿名用户可以上传 新建 删除 anon_upload_enable=YES anon_mkdir_write_enable=YES 3) 匿名用户限速500KBps anon_max_rate=500000

代码语言:javascript代码运行次数:0运行复制
<code class="javascript">仅供参考:#!/bin/bashipaddr=`ifconfig eth0|sed -n '2p'|sed -e 's/.*inet addr:\(.*\) Bcast.*/\1/g'`iptail=`echo $ipaddr|cut -d'.' -f4`ipremote=192.168.1.10#修改主机名hostname server$iptail.zutuanxue.comsed -i "/HOSTNAME/cHOSTNAME=server$iptail.zutuanxue.com" /etc/sysconfig/networkecho "$ipaddr server$iptail.zutuanxue.cc" >>/etc/hosts#关闭防火墙和selinuxservice iptables stopsetenforce 0 >/dev/null 2>&1sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config#配置yum源(一般是内网源)#test networkping -c 1 $ipremote > /dev/null 2>&1if [ $? -ne 0 ];thenecho "你的网络不通,请先检查你的网络"exit 1elseecho "网络ok."ficat > /etc/yum.repos.d/server.repo << end[server]name=serverbaseurl=ftp://$ipremoteenabled=1gpgcheck=0end#安装软件read -p "请输入需要安装的软件,多个用空格隔开:" softyum -y install $soft &>/dev/null#备份配置文件conf=/etc/vsftpd/vsftpd.conf\cp $conf $conf.default#根据需求修改配置文件sed -ir '/^#|^$/d' $confsed -i '/local_enable/c\local_enable=NO' $confsed -i '$a anon_upload_enable=YES' $confsed -i '$a anon_mkdir_write_enable=YES' $confsed -i '$a anon_other_write_enable=YES' $confsed -i '$a anon_max_rate=512000' $conf#启动服务service vsftpd restart &>/dev/null && echo"vsftpd服务启动成功"#测试验证chmod 777 /var/ftp/pubcp /etc/hosts /var/ftp/pub#测试下载cd /tmplftp $ipaddr <<endcd pubget hostsexitendif [ -f /tmp/hosts ];thenecho "匿名用户下载成功"rm -f /tmp/hostselseecho "匿名用户下载失败"fi#测试上传、创建目录、删除目录等cd /tmplftp $ipaddr << endcd pubmkdir test1mkdir test2put /etc/grouprmdir test2exitendif [ -d /var/ftp/pub/test1 ];then    echo "创建目录成功"if [ ! -d /var/ftp/pub/test2 ];then    echo "文件删除成功"        fielseif [ -f /var/ftp/pub/group ];thenecho "文件上传成功"        else        echo "上传、创建目录删除目录部ok"        fi fi   [ -f /var/ftp/pub/group ] && echo "上传文件成功"</code>

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
js正则表达式
js正则表达式

php中文网为大家提供各种js正则表达式语法大全以及各种js正则表达式使用的方法,还有更多js正则表达式的相关文章、相关下载、相关课程,供大家免费下载体验。

530

2023.06.20

正则表达式不包含
正则表达式不包含

正则表达式,又称规则表达式,,是一种文本模式,包括普通字符和特殊字符,是计算机科学的一个概念。正则表达式使用单个字符串来描述、匹配一系列匹配某个句法规则的字符串,通常被用来检索、替换那些符合某个模式的文本。php中文网给大家带来了有关正则表达式的相关教程以及文章,希望对大家能有所帮助。

258

2023.07.05

java正则表达式语法
java正则表达式语法

java正则表达式语法是一种模式匹配工具,它非常有用,可以在处理文本和字符串时快速地查找、替换、验证和提取特定的模式和数据。本专题提供java正则表达式语法的相关文章、下载和专题,供大家免费下载体验。

765

2023.07.05

java正则表达式匹配字符串
java正则表达式匹配字符串

在Java中,我们可以使用正则表达式来匹配字符串。本专题为大家带来java正则表达式匹配字符串的相关内容,帮助大家解决问题。

219

2023.08.11

正则表达式空格
正则表达式空格

正则表达式空格可以用“s”来表示,它是一个特殊的元字符,用于匹配任意空白字符,包括空格、制表符、换行符等。本专题为大家提供正则表达式相关的文章、下载、课程内容,供大家免费下载体验。

356

2023.08.31

Python爬虫获取数据的方法
Python爬虫获取数据的方法

Python爬虫可以通过请求库发送HTTP请求、解析库解析HTML、正则表达式提取数据,或使用数据抓取框架来获取数据。更多关于Python爬虫相关知识。详情阅读本专题下面的文章。php中文网欢迎大家前来学习。

293

2023.11.13

正则表达式空格如何表示
正则表达式空格如何表示

正则表达式空格可以用“s”来表示,它是一个特殊的元字符,用于匹配任意空白字符,包括空格、制表符、换行符等。想了解更多正则表达式空格怎么表示的内容,可以访问下面的文章。

244

2023.11.17

正则表达式中如何匹配数字
正则表达式中如何匹配数字

正则表达式中可以通过匹配单个数字、匹配多个数字、匹配固定长度的数字、匹配整数和小数、匹配负数和匹配科学计数法表示的数字的方法匹配数字。更多关于正则表达式的相关知识详情请看本专题下面的文章。php中文网欢迎大家前来学习。

547

2023.12.06

JavaScript浏览器渲染机制与前端性能优化实践
JavaScript浏览器渲染机制与前端性能优化实践

本专题围绕 JavaScript 在浏览器中的执行与渲染机制展开,系统讲解 DOM 构建、CSSOM 解析、重排与重绘原理,以及关键渲染路径优化方法。内容涵盖事件循环机制、异步任务调度、资源加载优化、代码拆分与懒加载等性能优化策略。通过真实前端项目案例,帮助开发者理解浏览器底层工作原理,并掌握提升网页加载速度与交互体验的实用技巧。

1

2026.03.06

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
进程与SOCKET
进程与SOCKET

共6课时 | 0.4万人学习

swoole入门物联网开发与实战
swoole入门物联网开发与实战

共15课时 | 1.3万人学习

swoole项目实战(第二季)
swoole项目实战(第二季)

共15课时 | 1.3万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号