// 获取
public static void fuctionDemo_5() {
String str = "yang cheng yong ben dan ba shi de ta hen sha";
String regex = "\\b[a-z]{3}\\b";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
while (m.find()) {
System.out.println(m.group());
}
}
public static void fuctionDemo_4() {
String str = "18758183839";
str = str.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
System.out.println(str);
}
// 分割1
public static void fuctionDemo_3() {
String str = "yang8888cheng222yong";
str = str.replaceAll("(.)\\1+", "$1");
System.out.println(str);
}
// 切割2
public static void fuctionDemo_2() {
String s1 = "yang cheng yong beng dan";
String[] names = s1.split(" +");
for (String name : names) {
System.out.println(name);
}
String s2 = "yang###sha@@@bi";
String[] names2 = s2.split("(.)\\1+");
for (String name : names2) {
System.out.println(name);
}
}
// 匹配手机号码是否正确
public static void fuctionDemo_1() {
String num = "15958184259";
String regex = "1[358][0-9]{9}";
boolean b = num.matches(regex);
System.out.println(num + ":" + b);
}
相关推荐
银河麒麟V10搭建vsftpd
1、查看是否有安装过2、安装3、服务启动步骤设置开机启动并此次立即启动启动重启停止查看状态4、系统防火墙放行ftp服务如果没有重要的数据在服务器里面,或者在本地虚拟机中外网无法访问的情况下,建议直接关闭防火墙即可省略以上繁琐的步骤。
正则中路径分隔符的匹配写法
项目中的 webpack 配置文件中有部分 loader 需要添加额外的过滤条件,需要使用正则表达式, 如: url-loader 处理图片,需要过滤掉 fonts 目录下的 svg 后缀的图片,之前一直在 windows 系统下编程,所以写成了 exclude: /src\\fonts/ 但是服务器打包后发现并没有过滤成功, 猜测是路径分隔符问题,查了一下才知道,正确的写法应该如下: excl...
麒麟银河操作系统V10部署ffmpeg(也能用于Linux系统)
部署ffmpeg用来处理视频的各种操作,如编码解码,格式转换,剪辑,处理实时视频流,音频流,加滤镜等
常用的正则表达式知识点与常见的正则匹配模式
一、常见符号的功能介绍 1、分隔符 分隔符可以是除了特殊字符以外的任何字符,常见的分隔符有:/、#、~等。例:/中间写正则表达式/ 2、元字符 ^ :匹配开头 例:/^ve/匹配以ve开头的 $:匹配结尾 例:/ve$/匹配以ve结尾的 . :用于匹配除换行符之外的所有字符 + :用来匹配元字符前的字符出现1次或者多次 * :用来匹配元字符前的字符出现0次或者多
机器人路径规划:基于冠豪猪优化算法(Crested Porcupine Optimizer,CPO)的机器人路径规划(提供MATLAB代码)
移动机器人(Mobile robot,MR)的路径规划是 移动机器人研究的重要分支之,是对其进行控制的基础。根据环境信息的已知程度不同,路径规划分为基于环境信息已知的全局路径规划和基于环境信息未知或局部已知的局部路径规划。随着科技的快速发展以及机器人的大量应用,人们对机器人的要求也越来越高,尤其表现在对机器人的智能化方面的要求,而机器人自主路径规划是实现机器人智能化的重要步骤,路径规划是指规划机器人从起点位置出发,无碰撞、安全到达指定目标位置的最优路径。
别再为PT100测温发愁了!手把手教你用ADS1247+STM32搞定高精度温度采集(附完整代码)
本文详细介绍了如何使用ADS1247与STM32构建高精度PT100测温系统,涵盖硬件设计、SPI配置、温度计算及调试技巧。通过24位ADC和内置PGA,实现0.1℃级精度,适用于工业自动化和医疗设备。附完整代码和常见问题解决方案,助你快速掌握高精度温度采集技术。
正则表达式学习笔记(转)
正则表达式学习笔记 正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串、将匹配的子串做替换或者从某个串中取出符合某个条件的子串等。 列目录时, dir *.txt或ls *.txt中的*.txt就不是一个正则表达式,因为这里*与正则式的*的含义是不同的。 为便于理解和记忆,先从一些概念入手,所有特殊字符或字符组合有一个总表在后面,
【实战指南】从零构建UNet多分类分割数据集:标注、转换与训练全流程
本文提供了一份从零构建UNet多分类分割数据集的完整实战指南。详细介绍了使用Labelme进行图像标注的核心技巧与规范,并通过Python脚本将标注结果转换为模型可用的VOC格式。最后,指导如何修改经典的PyTorch版UNet代码,以适配自定义数据集并进行训练与测试,帮助读者完成从数据准备到模型训练的全流程。
用正则表达式实现千分位分隔符
原创文章,转载请注明:http://blog.youkuaiyun.com/chang_yuan_2011/article/details/46836045 千位分隔符就是在数字中,每隔三位数加进一个逗号,实现的想法就是判断数字中是否有超过四个相连的数字,如果有就在他们中间插入逗号,直到找不到四个相连的数字为止。另外一点是拆分应该是从尾部开始。一开始将小数点转换成逗号作为整个搜索的起始位置,整个数句拆分完再
基于STM32的智能血氧、心率、体温、血压监测系统
摘要:本文设计了一款基于STM32F103C8T6的多功能健康监测系统,可实时检测血氧、心率、体温和血压四项生理参数。系统集成MAX30102、DS18B20等传感器模块,采用OLED显示和蓝牙无线传输技术,实现一键血压测量、阈值报警及手机APP数据管理功能。硬件设计包含传感器采集、电源管理、显示报警等模块;软件采用模块化架构,实现数据采集处理、蓝牙通讯等功能。测试表明系统测量准确可靠,为家庭健康监测提供了便携解决方案。未来可扩展更多监测参数和智能分析功能。
ADS基础教程24 - Gerber文件的导入
一、引言二、基本概念1.仿真文件下载2.仿真文件介绍二、导入步骤1.新建workspace2.选择Layout结构3.导入设计4.选择文件类型5.导入文件6.预览文件内容7.铜皮离散问题四、总结选择。通过本文章结束,可以了解ADS中如何将导入Gerber文件,并且对导入的铜皮进行合并。下一步就针对导入的文件进行层叠设置和编辑。END!}}END!
正则表达式
正则作用: 对字符串 1.分割 2.匹配 3.替换 4.搜索 常用正则 表示字符 含义 \d 一个数字【0-9】 \D 一个非数字 \w 一个字母【0-9】【a-z】【A-Z】 \W 一个非字母 . 任意一个字符 表示正则出现次数 修饰符 ? 修饰前一个正则出现的次数为0-1次 + 修饰符前面的正则表达式出现1次或多次 * 修饰符 修饰符前面的正则表达式出现0次或多次 [] : 字符选择器 举例: [0-9] :在指定范围中任意取一个值 [a
通过实例讲解瀑布模型
在电子商城开发中,瀑布模型如同 “工业时代的流水线”—— 能通过标准化流程交付高质量、高合规性的系统,但也可能因缺乏灵活性而错失市场机会。其优势与缺点本质上源于同一核心特征:严格的阶段性与文档驱动。决策建议若开发传统型、长周期、需求固定的电子商城(如企业内部采购平台),可优先选择瀑布模型,并通过 “需求预验证 + 模块化设计” 降低风险;若开发创新型、短周期、需快速迭代的电商平台(如社交电商、跨境电商),建议采用敏捷模型或混合模型(如瀑布 + Scrum),平衡规范性与响应速度。
运行一个命令或程序获取结果/正则表达式查找匹配/分隔字符串
<br />Process process1 = new ProcessBuilder("cat", "/opl/etc/system.prop").start(); BufferedReader br1 = new BufferedReader(new InputStreamReader(process1.getInputStream())); Pattern pattern = Pattern.compile("apps.setting.platformversion
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
华为的C语言编程规范.pdf
华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。
正则表达式正反向断言
(?=pattern):正向肯定预查,在任何匹配pattern的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如,“Windows(?=95|98|NT|2000)”能匹配“Windows2000”中的“Windows”,但不能匹配“Windows3.1”中的“Windows”。预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开始下一次匹
锂电池充电器电路设计 里面有电路
锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。
JAVA基础学习(二十六)--正则表达式
符合一规则的表达式:用于专门操作字符串。 正则表达式则必须依靠Pattern类与Matcher类,这两个类都在java.util.regex包中定义。Pattern类的主要作用是进行正则规范的编写,而Matcher类主要是执行规范,验证一个字符串是否符合其规范。
Data-Structures-and-Algorithm-Analysis-in-Java.pdf
作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...
python中哪一种匹配方式最好_详解Python 最短匹配模式
问题你正在试着用正则表达式匹配某个文本模式,但是它找到的是模式的最长可能匹配。 而你想修改它变成查找最短的可能匹配。解决方案这个问题一般出现在需要匹配一对分隔符之间的文本的时候(比如引号包含的字符串)。 为了说明清楚,考虑如下的例子:>>> str_pat = re.compile(r'"(.*)"')>>> text1 = 'Computer says "no...
Python学习路线:定义实现最短匹配的正则表达式
Python学习路线:定义实现最短匹配的正则表达式 1、需求 我们正在尝试用正则表达式对文本模式做匹配,但识别出来的是最长的可能匹配。相反,我们想将其修改为最短的可能匹...
C#通過时间字符串获取相应时间
2. 在C#中只想要獲取以下前面的數字,2024-11-08-09-41-43_FCT0000123456789。1.如何通過2024-11-08-10-00-47字符串,按照根據年月日時分秒順序獲取相應的時間。更复杂的模式匹配需求,你可以使用正则表达式来查找和提取字符串中的特定字符或字符序列。根据某个分隔符将字符串拆分成多个部分,并且你知道特定字符位于哪个部分中,你可以使用。3. 在C#中判斷字符串的第7位和第8位為大寫的GH,如何判斷。
正则表达式问题记录
【代码】正则表达式问题记录。
正则表达式案例
本文使用java演示 转载自:JS正则表达式完整教程(略长) 1、匹配16进制颜色 String str = "#ffbbad asda #f33 #ffdd11 #dsasaa "; Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}|#[a-fA-F0-9]{3}"); Matcher matcher = pattern.matcher(s...
java正则表达式改变字符串_java 中使用正则表达式操作字符串
importjava.awt.Toolkit;importjava.awt.datatransfer.Clipboard;importjava.awt.datatransfer.DataFlavor;importjava.awt.datatransfer.StringSelection;importjava.awt.datatransfer.Transferable;importjava.util...
JAVA正则表达式匹配,替换,查找,切割
importjava.util.ArrayList; importjava.util.regex.Matcher; importjava.util.regex.Pattern; publicclasstest{ publicstaticvoidmain(String[]args){ getStrings();//用正则表达式获取指定字符串内容中的指定内容 System.out.println("********************"); ...
18.1.3 正则表达式常用的四种功能
通常正则表达式都用于以下四种场合:查找、获取、分段、替换。 1.查找 事实上,查找功能是非常实用的一种功能,使用Matcher类的find方法即可实现查找功能。 2.获取 在正则表达式中可以利用group方法提取具体某个匹配结果。 3.分隔 如前面的章节讲解过,使用split方法可以将指定的字符串使用指定的正则表达式进行分隔。 4.替换 在字符串
Java小记——正则表达式
/\\D 和他的意思[^0-9] 一样。// 跟[^a-zA-Z_0-9] 意思一样。//\\转义字符 \\. 只代表.本身。//\\d 和他的意思[0-9] 一样。// 跟[a-zA-Z_0-9] 意思一样。
正则表达式的使用(C#)
1, C#中与正则表达式相关类。 C#中与正则表达式相关类的几个常用类是Regex,Match,Group,Captrue,RegexOption首先我们看看这几个类的类图关系,如何你有正则表达式基础,从这些方法和属性中就大概能明白使用方法了。 Regex:与正则表达式相关的操作必须通过它来执行的,它还提供了Match,IsMatch,Replace,Split几个静态的方法。 Resg...
6481



被折叠的 条评论
为什么被折叠?



