Jump to content
UBot Underground

scrape with Regex, but save without space


Recommended Posts

Hi :)

 

i´ll scrape adresses like this

<div class="address"> 
<h3>Christian Friedman</h3> 
<div class="adr"> Rosenstrasse 55<br>81335 München </div> </div>

and safe all, but the firstame without a space on the end. I have set this:

 

set(#first name, $find regular expression($list item(%info, 0), ".+ "), "Global")

and that´s it: Christian ,Friedmann,......   but not good for generate a #username like this:

 

set(#username, "{$table cell(&scraped info, #creation loop, 0)}0{$rand(1, 92)}", "Global")

Can anyone help me to safe the firstname or generate the username without this space ?  :)   thx
 

Link to post
Share on other sites
 

set(#first name, $find regular expression($list item(%info, 0), ".+ "), "Global")

 

 

The regex symbol for space is an escaped 's', like this: \s

 

Your code should look maybe rather like this:

 

set(#first name, $find regular expression($list item(%info, 0), "((.)+)"), "Global")

Notice the lack of spaces.

 

If you want to add a space, it should be:

 

set(#first name, $find regular expression($list item(%info, 0), "((.)+)\\s"), "Global")

 

If the space can be omitted sometimes, you could add a modifier:

 

set(#first name, $find regular expression($list item(%info, 0), "((.)+)\\s?"), "Global")

etc...

 

Play with your REGEX here:

 

http://rubular.com/

 

Hope it helps you...

  • Like 2
Link to post
Share on other sites

Thanks @VaultBoss for your help !  :)

 

The problem was not to scrape it with Regex, but i have found it !! I need to $trim the $find regular expression and it works.

 

I´m happy!  :D

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...