Jump to content

Strip everything after X


Recommended Posts

Ok well i have a script that copys a bunch of text but I need the first part of the text but not the second, is there any way to like make it remove everything after "__________" and keep the first half?

Send("^c")
Global $title = ClipGet()
Link to comment
Share on other sites

$array = StringSplit ($title, "__________" )

Msgbox(0,"The text you want is:",$array[1])

No?

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

  • Moderators

$array = StringSplit ($title, "__________" )

Msgbox(0,"The text you want is:",$array[1])

No?

I like this way alot personally, and use it alot, here is another alternative also:
ClipPut('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
MsgBox(0, '', _StripClipContent('M'))

Func _StripClipContent($vFind, $iCaseSensitive = 1, $sReturnBeforeAfter = 0)
    Local $vClipGet = ClipGet()
    If Not $sReturnBeforeAfter Then
        Return StringLeft($vClipGet, StringInStr($vClipGet, $vFind, $iCaseSensitive) -1 ); if $sReturnBeforeAfter = 0 returns string before the string to find
    Else
        StringMid($vClipGet, StringInStr($vClipGet, $vFind, $iCaseSensitive) + 1); returns the string after the string to find
    EndIf
EndFunc

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

I like this way alot personally, and use it alot, here is another alternative also:

ClipPut('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
MsgBox(0, '', _StripClipContent('M'))

Func _StripClipContent($vFind, $iCaseSensitive = 1, $sReturnBeforeAfter = 0)
    Local $vClipGet = ClipGet()
    If Not $sReturnBeforeAfter Then
        Return StringLeft($vClipGet, StringInStr($vClipGet, $vFind, $iCaseSensitive) -1 ); if $sReturnBeforeAfter = 0 returns string before the string to find
    Else
        StringMid($vClipGet, StringInStr($vClipGet, $vFind, $iCaseSensitive) + 1); returns the string after the string to find
    EndIf
EndFunc
hmm :)
Link to comment
Share on other sites

Glad i could help. :)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Ok well they both work very well (thanks, oh and kandie introduced me to StringSplit so thanks), but I am going to have to use this method multiple times. But I am going to use SmOke_N's :)

Thank you very much, ill be back in a month to ask another question :(

Edited by blizzedout
Link to comment
Share on other sites

Hi,

isn't there the second return missing??? :)

Return StringMid($vClipGet, StringInStr($vClipGet, $vFind, $iCaseSensitive) + 1)

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Moderators

Hi,

isn't there the second return missing??? :)

Return StringMid($vClipGet, StringInStr($vClipGet, $vFind, $iCaseSensitive) + 1)

So long,

Mega

Of course...

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

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...