regex

How can I replace all £ in a file with £ with Perl?

I am trying to replace all £ symbols in a HTML file with £. My regular expression does not seem to work. Could you please help? ...

Analyse Windows event log entries using PowerShell and regular expressions

I'm currently working on a PowerShell script to analyse VPN traffic by reading the event log of our VPN server. I'm using WMI to retrieve the relevant event entries and a regular expression to extract information like user name, traffic etc. The event message obviously does contain line breaks which I don't seem to be able to match via ...

Free alternative(s) to PowerGREP

First of all, great praise goes out to PowerGREP it's a great program. But it's not free. Some of it's options I'm looking for: Being able to use .NET regexp's (or similar) to find things in a filtered list of files through subdirectories. Replacing that stuff with other regexps. Being able to jump to that part of the file in some ...

Problems with XML encoding in perl xml Lib

Replacing the Special Character using Perl while i am doing this . I got this error . I just try to merging the 2 xml file using XML::Lib. parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xA3 0x32 0x33 0x6B �23 to c�27 . What is the issue and how to resolve this this I thought before going to XML Parser , I...

PHP RegEx Grouping Multiple Matches

I'm just trying my hand at crafting my very first regex. I want to be able to match a pseudo HTML element and extract useful information such as tag name, attributes etc.: $string = '<testtag alpha="value" beta="xyz" gamma="abc" >'; if (preg_match('/<(\w+?)(\s\w+?\s*=\s*".*?")+\s*>/', $string, $matches)) { print_r($matches); } ...

Scala Regex enable Multiline option

Hi, I'm learning Scala, so this is probably pretty noob-irific. I want to to a multiline regular expression. In Ruby it would be: MY_REGEX = /com:Node/m My Scala looks like: val ScriptNode = new Regex("""<com:Node>""") Here's my match function: def matchNode( value : String ) : Boolean = value match { case ScriptNode() =>...

Php put a space in front of capitals in a string (Regex)

I have a number of strings which contain words which are bunched together and I need to seperate them up. For example ThisWasCool - This Was Cool MyHomeIsHere - My Home Is Here Im slowly getting my head around regular expressions and I believe to do this I should use preg_replace. My problem is putting together the expression to find t...

Regular expression to grab link between square brackets

I need to lift the YouTube link from some text which looks like this: [youtube=http://www.youtube.com/v/qpbAe2HyzqA&hl=en&fs=1&] Can anyone help? ...

At witt's end... Javascript won't replace '\n'!

Hey guys, I've been going at this problem for a solid couple hours now and having zero luck. No clue how this is even possible; I'll try to summarize. I'm using TinyMCE to insert new content to a DB, that content is being sent back as an AJAX response after it is inserted into the DB and then shown on the page, replacing some old cont...

UrlRewriting.Net Regular expression - "Not in string"

hi there, i may be barking up the wrong tree here but i'm banging my head against a wall trying to write a regex rewrite. i have two site that are identical but by choice the client uses one server (call it http://www1.test.com) to host part of the site to take load off the other. i am using urlrewriting.net and so far have setup the ...

Why doesn't this Perl regex work?

I have a Perl script, that's supposed to match this string: Sometimes, he says "hey fred, what's up?" It says if it found fred at the beginning, end, or middle of the word, or if it just found "fred". So it matches Alfred, and Frederich. Well, in this string, it's supposed to say it found fred on its own, but it's saying it found it a...

checking a pattern present in a string using javascript

How to check if a url or url pattern is presnt or not in a string using javascript. <script language="javascript"> var str="http://localhost/testprj?test=123213123"; var s=location.href; if(s.match('/http://localhost/testprj?test=1232/'){ alert('welcome!!'); } </script> what i need is to check the url pattern. complete code <htm...

Named Groups in Regular Expression

Hi, I want to parse the input string and extract the values from it. My input string might have Week, Days, Hours or Minutes. So, the input string might be 1 Week 5 Days 2 Hours 1 Minutes where or 3 minutes Or 5 Days 1 Minute Or 2 Hours etc. I want to extract the values using a regular expression. How can I achieve this in ....

RegEx to get numbers between periods in IP address?

Say you have an IP address: 74.125.45.100 so its A.B.C.D Is there a way to use RegEx to get A,B,C separately? ...

simple preg_replace() that I can't get working (i suck at regex)

$count_sql = preg_replace("/SELECT(.+?)FROM/", "SELECT COUNT(*) FROM", $sql); It's probably pretty obvious what I'm trying to do, but I am terrible with regex. I need to replace anything between SELECT and FROM with COUNT(*). Tried using (.+), (.+?), (.*), and (.*?). ...

How to validate characters ONLY in ColdFusion CFForm?

I've got a very simple cfform with a single form field: <cfform action="asdf.cfm" method="post"> <cfinput name="fieldName" type="text" size="20" maxlength="20" required="yes" validate="regex" pattern="[A-Za-z]" message="Only characters are allowed." /> <input type="submit" name="btnSubmit" value="check" /> </cfform> Theoretically,...

Parsing a String in Ruby (Regexp?)

I've got a string Purchases 10384839,Purchases 10293900,Purchases 20101024 Can anyone help me with parsing this? I tried using StringScanner but I'm sort of unfamiliar with regular expressions (not very much practice). If I could separate it into myarray[0] = {type => "Purchases", id="10384839"} myarray[1] = {type => "Purchases", id...

Finding partial strings in a list of strings - python

I am trying to check if a user is a member of an Active Directory group, and I have this: ldap.set_option(ldap.OPT_REFERRALS, 0) try: con = ldap.initialize(LDAP_URL) con.simple_bind_s(userid+"@"+ad_settings.AD_DNS_NAME, password) ADUser = con.search_ext_s(ad_settings.AD_SEARCH_DN, ldap.SCOPE_SUBTREE, \ "sAMAccountName...

Subdirectory Rewrite | Include All Relative Stuff

I'm trying to hide actual sub-directory from url path using mod_rewrite. The folder actual name is members and i want users to use area instead. The code I'm using works but no images or relative stuff is loading. The rule is missing certain parameters. Can you point me in the right direction? RewriteEngine on RewriteRule ^area/$ /mem...

Search and replace on Eclipse

What's the syntax to perform a search/replace on Eclipse and use "match groups" ( is that it's name? " On vi I: %s/log(.*)/log \1 debug/g And lines like: log "Message" are replaced with log "Message" debug What's the correct syntax for eclipse in the search/replace dialog box ( beside checking up "Regular expressions" ) Than...