I was trying to solve a problem through regex. but It's very hard to make the regex. let look to an example maybe you people can help me out. and gave me some good source to learn regex. Now my problem is I want to make the regex for a sentence. e.g www.facebook.com www.goole.com www.online.facebook.com www.live.com if you see these example the www and com is same but the data between these are changing. i tried to make through this link but can't.
I'm lousy at regular expressions but occasionally they're the only thing that's the right solution for a problem.
Is there something in the .NET framework that allows you to input an unencoded string and get a pattern from it? Which you could then modify as required?
e.g. I want to remove a CDATA section that contains a file from some XML but I can't work out what the right pattern is for <![CDATA[hugepileofrandombinarydataherethatalsoneedstogo]]> and I don't want to ask for help each time I'm stuck on a regex pattern.
Such tools exist, google by "regex generator".
But, as suggested in comments, better learn regex. Simple patterns are easy. Something like <!\[.*?]]>
in your case.
There are Regex Design tools like expresso...
http://www.ultrapico.com/expresso.htm
It's not perfect but as there is no suitable .Net component the text to regex page at txt2re.com is the best I've seen for those people who occasionally need to build a regex to match a string but don't have the time to relearn regex each time they want to use one.
I tried to make regex syntax for that but I failed.
I have 2 variables
PlayerInfo[playerid][pLevel]
and
Character[playerid]
and I want to catch only the second variable,I mean only the world what don't contain PlayerInfo, but cointains [playerid]
"(\S+)\[playerid\]" cath both words and (\S+[^PlayerInfo])\[playerid\] jump on some variables- they contais p,l,a,y ...
I need to replace in notepad++,all variables like Text[playerid] to ExClass [playerid][Text]
Couple Pluasible solutions.
List item
Notepad has a plugin called python script. Running regex from there
gives full regex functionality, the python version anyway, and a lot
of powerful potential beyond that. And I use the online python regex tester to help out.
RegRexReplace plugin helps create regex plugins in Notepad++, so when you do hit a limitation, you find out a lot quicker.
Or of course default to your alternate editor (I'm assuming you have
one?) or this online regex tool is absolutely amazing. You
can perform the action on the text online as well.
(I'd try to build a regex for you, but I'm a bit lost as to what you're looking for. Unless the Ivo Abeloos got it. If you're still coming up short, maybe a code example along with values displayed?)
Good luck!
It seems that Notepad++ support negative lookbehind since v6.
In notepad++ you could try to replace (.+)\[(.+)\] with ExClass\[\2\]\[\1\]
Try to use negative lookbehind.
(?<!PlayerInfo)\[playerid\]
EDIT: unfortunately notepad++ does not support negative lookbehind.
I tried to make a workaround based on the following naive idea:
(.[^o]|[^f]o)[playerid]
But this expression does not work either. Notepad++ seems to fail in alternative operator. Thus the answer is: it is impossible to do exactly what you want. Try to solve the problem in other way or use alternative tool.
I've been having a need to do a lot of regex / pattern-matching stuff lately and, in looking at different examples / forum posts from my web searches it seems people sometimes mention that perl has good modules to help in simplifying pattern matching / regex tasks, however they neglect to mention which ones are the best for this.. I have looked at CPAN for this but their site isn't very easy to navigate as I can't seem to search effectively by category.. any advice is appreciated.
Take a look at Regexp::Common
Also, look at YAPE::Regex::Explain and the web front end to it. Invaluable.
Might I suggest the perl6-esque Regexp::Grammars if you're doing anything really complex and need to write a grammar -- it is really awesome. I just used it to parse a few SQL commands for my perl postgresql shell: pgperlshell
A lot of the power of regular expressions is available natively in perl. Probably the best way for you to simplify your understanding of perl regular expressions is to read the excellent perl regex tutorial at http://perldoc.perl.org/perlretut.html
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I tried some regex tools like Regulator, Regulazy & RegexBuddy. They don't do what I want and they expect the user to know regular expressions.
I want a tool for dummies. You tell the tool I need a regex for something like "match anything that ends with the word 'yes' and it contains at least one occurrence of the phrase '/test/'" and it creates the regex for you.
So I either enter my request in plain English or semi plain English or the tool has all kinds of ready made selections and I choose between them to create what I want ad hoc.
Is there such a tool which is geared towards non developers? I am not looking for a regex tester.
I have been a fan of Ultrapico's Expresso application. There is a builder section that helps you (a little) in building fragments of the expression. More importantly it will explain an existing expression (either your own or from the built in expression library) section by section.
It also includes a testing and replacement section to see and test your expressions. Lastly it will generate the expression formatted for either C#, C++, or VB.NET so that you know exactly how to insert the expression into your project.
Best of all it's free. I have been using this tool to help learn how regular expressions actually work, especially the complex ones. Can't say it makes writing expressions idiot proof but it has sure made learning expressions easier for me...
This tool was featured in a MSDN Webcast by Zain Naboulsi, and might be worth a watch. Hope this helps, and good luck with your Regex journey!
txt2re seems really good. I entered "This string contains test in it and ends in yes" into the box, clicked on test and yes, and
got a regular expression. It doesn't focus on teaching how to build regexes, but it shows you the perl code to parse what you need.
The real power of this tool is its ability to recognize things like dates, URLs, and tags. Whitespace didn't seem to work too well, however, and it doesn't appear to handle any sort of repetition.
Personally I really like Expresso http://www.ultrapico.com/Expresso.htm
The interface is quite clean - lets you test out search and replace functionality, has good help, plus it generates the C# expressions for you if you like.
For me, the best tool is RegexBuilder it's open source and writen in C#, so you can customize it as much as you want ;)
Enjoy. ;)
For web-based (one line only): http://txt2re.com/
For offline (Full text file is possible): Expresso
I like my own RegEx Builder best: http://www.linuxintro.org/regex
I am not sure such a tool exists, since they usually do the opposite:
Analyze a regexp and translate it in plain English.
The closest solution to your need would be this C# library, allowing you to program regexp in a semi-readable way:
Instead of this:
const string findGamesPattern =
#"<div\s*class=""game""\s*id=""(?<gameID>\d+)-game""(?<content>.*?)<!--gameStatus\s*=\s*(?<gameState>\d+)-->";
You would have, using ReadableRex:
Pattern findGamesPattern = Pattern.With.Literal(#"<div")
.WhiteSpace.Repeat.ZeroOrMore
.Literal(#"class=""game""").WhiteSpace.Repeat.ZeroOrMore.Literal(#"id=""")
.NamedGroup("gameId", Pattern.With.Digit.Repeat.OneOrMore)
.Literal(#"-game""")
.NamedGroup("content", Pattern.With.Anything.Repeat.Lazy.ZeroOrMore)
.Literal(#"<!--gameStatus")
.WhiteSpace.Repeat.ZeroOrMore.Literal("=").WhiteSpace.Repeat.ZeroOrMore
.NamedGroup("gameState", Pattern.With.Digit.Repeat.OneOrMore)
.Literal("-->");
I was also using Expresso, and found it quite good. The most important thing for me in these tools is validation and not so much visual aids for building expressions. I only need a tool to kind of remind me things, not design them for me.
Anyway, here's another free one, which I quite like. It's called Rad Software Regular Expression Designer. Hope this helps.
Try RegExr a flash based tool
If you are a mac person, try this widget, althought it's also a tester i find it quite useful as it's really easy to get to it while learning regex online
http://mac.softpedia.com/progDownload/Regex-Widget-Download-28467.html
I settled on RegexBuddy. It has a debugger, visualizer and translates the regex into plain English.
Well it's still very much a tool in development, but you could try Textpression at http://www.textpression.com Disclosure: I'm the author.
Textpression enables visual regex creation with a drag and drop editor; no regex syntax to learn! At time of writing Textpression is still in Alpha, but let me know what you think!
Intuitive Regular Expression Analyser and Composer Class (for PHP, Node/JS and Python), regex composer live example here
RegexAnalyser github repository
ps i am the author
As per details in your question, I think Regex Builder Tool is the exact tool you need.
For the regex you asked in question, you would give requirements in simple plain english like _Match_anywhere_in_text_ _zero_or_more_of_ ( _any_character_) _then_ _one_or_more_of_ ( _exact_string_ ( test)) _then_ _zero_or_more_of_ ( _any_character_) _then_ _exact_string_ ( yes) _then_ _end_of_line_
This would automatically generate regex .*test+.*yes$ You can also test generated regex right there using input like I did test, results yes & it would show that generated regex is matching the text as per your expectations.