Jump to content

regexp help - how to extract certain strings


 Share

Recommended Posts

Btw, we can (re)use \1 inside the pattern:

$sWeb_Site = 'somewebsite.com'
$sString = '<a href="http://' & $sWeb_Site & '">' & $sWeb_Site & '</a>'

$sRet = StringRegExpReplace($sString, '(?i)<(\w+) href="http://(.*?)">\2</\1>', '\2')

ConsoleWrite($sRet & @CRLF & @extended & @CRLF)

Not sure why we need it, but it's good to know :P

Wow!

I didn't know

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • Moderators

Going back to the original problem, here is a non-regexp way of doing this using the little-used _StringBetween....

#include <array.au3>
#Include <String.au3>

$string = '<a href="/name/lockie" class="plain">Lockie</a> <a href="/name/aram-1" class="plain">Aram</a>'
$array = _StringBetween($string,">","<")
$string = _ArrayToString($array,"")

MsgBox(0,"",$string)
Oops, I wrote _StringBetween using RegEx as default :P

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Oops, I wrote _StringBetween using RegEx as default :P

lol. It's a superb function anyway!

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...