Jump to content

Remove dashes from text ?


Go to solution Solved by elmoi0010,

Recommended Posts

Posted

Hello gusy i want to remove dashed from a text. I removed spaced with "StringStripWS" but i want to remove dashes now. i tryed wirh " StringRegExpReplace " but its not working i dont know. this is my code:

$sPhoneNumber = _StringBetween(_IEDocReadHTML($oIE) , 'Phone Number:</b> ', '</TD>')
If Not @error then
    MsgBox(4096,"Info", $sPhoneNumber[0])
Else
    MsgBox(4096,"Error", "Can not find phone number")
 EndIf

Anyone can help me ?

  • Moderators
Posted

elmoi0010,

Have you tried StringReplace - it is simpler to use than its SRER cousin. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 1/19/2014 at 2:48 PM, Melba23 said:

elmoi0010,

Have you tried StringReplace - it is simpler to use than its SRER cousin. ;)

M23

i tryed the example of stringreplace webpage ---> source, and it work but i tryed to implement to my code but its not working :S.

  • Moderators
Posted

elmoi0010,

 

  Quote

my code but its not working

And how do you think that is going to help us find a solution? Please post the code which does not work - see here how to do it. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Solution
Posted

  On 1/19/2014 at 2:58 PM, michaelslamet said:

Sorry it should be "-"

Sorry for the typo i am typing from a phone :)

Thanks you so much bro it works <3 you are the best :D!

Posted (edited)

There are several types of hyphens and dashes you may try this:

p{Pd} or p{Dash_Punctuation}: any kind of hyphen or dash as in:

StringRegExpReplace($filewhole1, '(*UCP)\p{Pd}', '-')

seems to work for me.

From http://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions:

Since version 8.10, matching of certain "normal" metacharacters can be driven by Unicode properties when the compile option PCRE_UCP is set. The option can be set for a pattern by including (*UCP) at the start of pattern.
 

In fact if you go here and scroll down to Unicode Categories you'll find lots of interesting regex expressions we now can use. Some work in ascii and unicode encoding - give them a try!

http://www.regular-expressions.info/unicode.html

Joe

Edited by Jury

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
  • Recently Browsing   0 members

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