Regular Expression Basic Syntax Reference

RegexBuddyEasily create and understand regular expressions today. Compose and analyze regex patterns with RegexBuddy's easy-to-grasp regex blocks and intuitive regex tree, instead of or in combination with the traditional regex syntax. Developed by the author of this website, RegexBuddy makes learning and using regular expressions easier than ever.Get your own copy of RegexBuddy now, and get a FREE printable PDF version of the regex reference on this website.

Regular Expression Basic Syntax Reference

Characters
CharacterDescriptionExample
Any character except [\^$.|?*+()All characters except the listed special characters match a single instance of themselves.{ and} are literal characters, unless they're part of a valid regular expression token (e.g. the{n} quantifier).a matches a
\ (backslash) followed by any of [\^$.|?*+(){}A backslash escapes special characters to suppress their special meaning.\+ matches +
\Q...\EMatches the characters between \Q and \E literally, suppressing the meaning of special characters.\Q+-*/\E matches +-*/
\xFF where FF are 2 hexadecimal digitsMatches the character with the specified ASCII/ANSI value, which depends on the code page used. Can be used in character classes.\xA9 matches © when using the Latin-1 code page.
\n, \r and \tMatch an LF character, CR character and a tab character respectively. Can be used in character classes.\r\n matches a DOS/Windows CRLF line break.
\a, \e, \f and \vMatch a bell character (\x07), escape character (\x1B), form feed (\x0C) and vertical tab (\x0B) respectively. Can be used in character classes. 
\cA through \cZMatch an ASCII character Control+A through Control+Z, equivalent to\x01 through\x1A. Can be used in character classes.\cM\cJ matches a DOS/Windows CRLF line break.
Character Classes or Character Sets [abc]
CharacterDescriptionExample
[ (opening square bracket)Starts a character class. A character class matches a single character out of all the possibilities offered by the character class. Inside a character class, different rules apply. The rules in this section are only valid inside character classes. The rules outside this section are not valid in character classes, except for a few character escapes that are indicated with "can be used inside character classes". 
Any character except ^-]\ add that character to the possible matches for the character class.All characters except the listed special characters.[abc] matches a, b or c
\ (backslash) followed by any of ^-]\ A backslash escapes special characters to suppress their special meaning.[\^\]] matches ^ or]
- (hyphen) except immediately after the opening [Specifies a range of characters. (Specifies a hyphen if placed immediately after the opening[)[a-zA-Z0-9] matches any letter or digit
^ (caret) immediately after the opening [Negates the character class, causing it to match a single characternot listed in the character class. (Specifies a caret if placed anywhere except after the opening[)[^a-d] matches x (any character except a, b, c or d)
\d, \w and \sShorthand character classes matching digits, word characters (letters, digits, and underscores), and whitespace (spaces, tabs, and line breaks). Can be used inside and outside character classes.[\d\s] matches a character that is a digit or whitespace
\D, \W and \SNegated versions of the above. Should be used only outside character classes. (Can be used inside, but that is confusing.)\D matches a character that is not a digit
[\b]Inside a character class, \b is a backspace character.[\b\t] matches a backspace or tab character
Dot
CharacterDescriptionExample
. (dot)Matches any single character except line break characters \r and \n. Most regex flavors have an option to make the dot match line break characters too.. matches x or (almost) any other character
Anchors
CharacterDescriptionExample
^ (caret)Matches at the start of the string the regex pattern is applied to. Matches a position rather than a character. Most regex flavors have an option to make the caret match after line breaks (i.e. at the start of a line in a file) as well.^. matches a in abc\ndef. Also matches d in "multi-line" mode.
$ (dollar)Matches at the end of the string the regex pattern is applied to. Matches a position rather than a character. Most regex flavors have an option to make the dollar match before line breaks (i.e. at the end of a line in a file) as well. Also matches before the very last line break if the string ends with a line break..$ matches f in abc\ndef. Also matches c in "multi-line" mode.
\AMatches at the start of the string the regex pattern is applied to. Matches a position rather than a character. Never matches after line breaks.\A. matches a in abc
\ZMatches at the end of the string the regex pattern is applied to. Matches a position rather than a character. Never matches before line breaks, except for the very last line break if the string ends with a line break..\Z matches f in abc\ndef
\zMatches at the end of the string the regex pattern is applied to. Matches a position rather than a character. Never matches before line breaks..\z matches f in abc\ndef
Word Boundaries
CharacterDescriptionExample
\bMatches at the position between a word character (anything matched by\w) and a non-word character (anything matched by[^\w] or \W) as well as at the start and/or end of the string if the first and/or last characters in the string are word characters..\b matches c in abc
\BMatches at the position between two word characters (i.e the position between\w\w) as well as at the position between two non-word characters (i.e.\W\W).\B.\B matches b inabc
Alternation
CharacterDescriptionExample
| (pipe)Causes the regex engine to match either the part on the left side, or the part on the right side. Can be strung together into a series of options.abc|def|xyz matches abc,def orxyz
| (pipe)The pipe has the lowest precedence of all operators. Use grouping to alternate only part of the regular expression.abc(def|xyz) matches abcdef orabcxyz
Quantifiers
CharacterDescriptionExample
? (question mark)Makes the preceding item optional. Greedy, so the optional item is included in the match if possible.abc? matches ab orabc
??Makes the preceding item optional. Lazy, so the optional item is excluded in the match if possible. This construct is often excluded from documentation because of its limited use.abc?? matches ab orabc
* (star)Repeats the previous item zero or more times. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is not matched at all.".*" matches "def" "ghi" inabc "def" "ghi" jkl
*? (lazy star)Repeats the previous item zero or more times. Lazy, so the engine first attempts to skip the previous item, before trying permutations with ever increasing matches of the preceding item.".*?" matches "def" inabc "def" "ghi" jkl
+ (plus)Repeats the previous item once or more. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is matched only once.".+" matches "def" "ghi" inabc "def" "ghi" jkl
+? (lazy plus)Repeats the previous item once or more. Lazy, so the engine first matches the previous item only once, before trying permutations with ever increasing matches of the preceding item.".+?" matches "def" inabc "def" "ghi" jkl
{n} where n is an integer >= 1Repeats the previous item exactly n times.a{3} matches aaa
{n,m} where n >= 0 and m >= nRepeats the previous item between n and m times. Greedy, so repeating m times is tried before reducing the repetition to n times.a{2,4} matches aaaa,aaa oraa
{n,m}? where n >= 0 and m >= nRepeats the previous item between n and m times. Lazy, so repeating n times is tried before increasing the repetition to m times.a{2,4}? matches aa,aaa oraaaa
{n,} where n >= 0Repeats the previous item at least n times. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is matched only n times.a{2,} matches aaaaa inaaaaa
{n,}? where n >= 0Repeats the previous item n or more times. Lazy, so the engine first matches the previous item n times, before trying permutations with ever increasing matches of the preceding item.a{2,}? matches aa inaaaaa

内容概要:本文系统性地介绍了基于“断线解环”思想的配电网辐射状拓扑约束建模方法,旨在通过Matlab代码实现,复现顶级EI论文中的核心技术。该方法聚焦于保障配电网在运行过程中维持严格的辐射状结构,防止环路形成,从而提高系统的安全性、稳定性和运行效率。文章深入阐述了如何利用混合整数线性规划(MILP)等优化技术处理复杂的拓扑约束条件,并结合标准配电网络进行仿真验证,特别适用于含分布式电源接入的现代复杂配电网。资源包不仅包含完整的Matlab实现代码,还整合了大量前沿科研方向的相关代码与资料,涵盖微电网优化调度、电动汽车协同管理、风光储联合系统、路径规划、深度学习预测等多个热门领域,并提供YALMIP等建模工具的支持,极大地方便了科研人员的学习、复现与二次开发。; 适合人群:具备电力系统、自动化、电气工程或相关工科专业背景,熟练掌握Matlab/Simulink仿真环境,正在从事电力系统优化、智能电网、分布式能源等领域科研或工程应用的人员,尤其适合研究生、博士生及具有一定科研基础的工程师。; 使用场景及目标:① 深入理解并掌握配电网辐射状拓扑约束的数学建模原理与“断线解环”策略的核心思想;② 成功复现高水平EI/SCI期刊论文中的优化模型与算法流程;③ 借助所提供的丰富案例代码,快速开展微电网经济调度、电动汽车优化、新能源预测、多目标优化等方向的科研项目;④ 熟练运用YALMIP等高级建模语言进行电力系统优化问题的建模、求解与分析。; 阅读建议:建议读者优先关注网盘中提供的完整代码、说明文档及示例数据,严格按照资源目录结构循序渐进地学习,重点剖析“断线解环”在消除环路、保证拓扑可行性方面的具体实现逻辑。务必亲自动手运行、调试和修改Matlab代码,以深化对理论模型与编程实现之间联系的理解。同时,可充分利用文中列举的其他研究主题作为灵感来源,拓展自身的科研视野与创新思路。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值