How do I make regex ignore all text between x and y within a string?

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
I cant just do replace because the content within the string will change.

I finally found out a convouted regex for the pinterest follow and unfollow so I cna use for a logic swtich but to get only the button for the specific user requires it to grab alot of unwanted text which will be chaigng every time.

So how do I regex to ignore all text that I don;t want.

I was looking online but it was only showing stuff to ignore specific characters which is no good since it wil be many chaigng characters all the time.

So for example in the sentence: "This is a sentence."

How could I for instance ignore "is a" so regex would only pickup "This sentence" bearing in mind the words "is a" will change all the time never knowing what those words would be.
 
Последнее редактирование:

Tobbe

Client
Регистрация
01.08.2013
Сообщения
428
Благодарностей
148
Баллы
43
Would be easier if you gave us the code where you'd like to grab the text from instead.
You could use a wildcard, just make sure it grabs something unique so other stuff don't get caught in it.
The ID attribute often is good (Actions Designer).

For example : "This.*?\ sentence"
Would match: "This is a long damn sentence", "This is a few word, ending with a sentence".
 

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
Didnt work :(

Here is the same code. I need it to take from the username KazzycaboodlesCreations which I will make to a variable for differing usernames down to the very last bit which says </button>.

Код:
class="userFocusImage" style="" alt="KazzycaboodlesCreations">
</span>

                                <span class="thumbContainer  ">
            <span class="hoverMask"></span>
            <img src="http://media-cache-ec0.pinimg.com/75x75/90/9c/b5/909cb59000f7414e0e7d8dc256ded993.jpg" class="userPin thumb" style="">
        </span>
                    <span class="thumbContainer  rightWrap ">
            <span class="hoverMask"></span>
            <img src="http://media-cache-ec0.pinimg.com/75x75/0c/a1/72/0ca17215c2be4895b79443dcea4b4dbb.jpg" class="userPin thumb" style="">
        </span>
                    <span class="thumbContainer  ">
            <span class="hoverMask"></span>
            <img src="http://media-cache-ec0.pinimg.com/75x75/dd/ff/68/ddff683cef28611da532270739756048.jpg" class="userPin thumb" style="">
        </span>
                    <span class="thumbContainer  rightWrap ">
            <span class="hoverMask"></span>
            <img src="http://media-cache-ak0.pinimg.com/75x75/fb/f3/33/fbf3333d4a0d906fe34fa0c46994c235.jpg" class="userPin thumb" style="">
        </span>
            </div>
    </a>
            <button id="" data-element-type="62" type="button" class="UserFollowButton btn rounded Button hasText gridItem Module ajax notNavigatable ui-FollowButton default">Follow</button>
-----

Here you can see the differece in code between unfollow/follow:

Код:
class="userFocusImage" style="" alt="KazzycaboodlesCreations">
</span>

                                <span class="thumbContainer  ">
            <span class="hoverMask"></span>
            <img src="http://media-cache-ec0.pinimg.com/75x75/90/9c/b5/909cb59000f7414e0e7d8dc256ded993.jpg" class="userPin thumb" style="">
        </span>
                    <span class="thumbContainer  rightWrap ">
            <span class="hoverMask"></span>
            <img src="http://media-cache-ec0.pinimg.com/75x75/0c/a1/72/0ca17215c2be4895b79443dcea4b4dbb.jpg" class="userPin thumb" style="">
        </span>
                    <span class="thumbContainer  ">
            <span class="hoverMask"></span>
            <img src="http://media-cache-ec0.pinimg.com/75x75/dd/ff/68/ddff683cef28611da532270739756048.jpg" class="userPin thumb" style="">
        </span>
                    <span class="thumbContainer  rightWrap ">
            <span class="hoverMask"></span>
            <img src="http://media-cache-ak0.pinimg.com/75x75/fb/f3/33/fbf3333d4a0d906fe34fa0c46994c235.jpg" class="userPin thumb" style="">
        </span>
            </div>
    </a>
            <button data-element-type="62" type="button" class="dim UserFollowButton btn rounded Button hasText gridItem Module ajax notNavigatable ui-FollowButton">


       


  


<span class="buttonText">Unfollow</span>
        </button>
I've managed to get it all with regex:

Код:
(?<=class="userFocusImage"\ style=""\ alt="KazzycaboodlesCreations">)[\w\W]*?(?=</button>)
Now I just have to get rid of the rest in between.
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
DUDE... dont make sience fiction out of simple things! Why the hell would you need switch for follow/unfollow? Simple negative exit is enough.

Now regarding your regex in order to click follow or unfollow... well i have attached example template so you can see how it is done.

Now please attach txt file with part of code you are picking only certain user button so i can show you how it is done. Beside, you can always regex out things in two or more steps if you cant extract what you need in first step.
 

Вложения

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
I presume you posted that before I posted the code? As I say above its not a simple case of follow and unfollow clicks, its also got to be related to that specific user only because the results often show many results on the page all with their own folow and unfolow buttons, so it must only click the right button follow or unfollow. It has to recognise which button it is first cos I save username to different files depending on which it is.
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
yes i posted it before...

Without using C# your best option would be next:

  1. Take DOM with regex you used for example and put all results to list.
  2. Now set counter to count loops.
  3. Go pick first line from that list.
  4. Regex it and check if it is matching what you need.
  5. If not loop again and increase counter...

When you find your match then all you need to do is put that counter number variable into Click Follow or UnFollow action under match number.

that is it, simple as that. :D
 

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
I tried taking DOM and source but it throws an error and won't find it either when it's on follow or unfollow but when I try it manually in copy to regex it finds the match. So why not in take text regex?
 

Tobbe

Client
Регистрация
01.08.2013
Сообщения
428
Благодарностей
148
Баллы
43
I tried taking DOM and source but it throws an error and won't find it either when it's on follow or unfollow but when I try it manually in copy to regex it finds the match. So why not in take text regex?
Post the link here, or PM me, with an url to one of those pages where there's several of those buttons. I could create you an example of the method drvosjeca mentioned above.
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
common man, you are not seriouse... I have explained everything step by step and you are still stuck. DOM didnt work probably because you didnt ad some pause to wait till page is fully downloaded.

Here i have uploaded example with everything included.

Now go and click "THANK YOU" button atleast 133 times. :D
 
  • Спасибо
Реакции: shabbysquire

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
Ah and there is your usual arrogant attitude I always remembered.

The page was already loaded.
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
.
 
Последнее редактирование:

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
I see there is no attachment i added... Here you go again

im arrogant?

OK man, sorry for bothering you and spending my time to help you!
 

Вложения

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
You help but treat people like they are stupid for not getting something instantly.
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
#1. I never said or treated you as you were stupid... My respond was just to fact that you said that get DOM is not working.

#2. If i was in your place I would just say "thank you for helping me" instead calling me arrogant. In the end you are the one that needs help and people who are willing to help you should be apreciated no matter what.

#3. Dont worry, I wont be arrogant in future and I sure wont spend my time again in order to help you!


Now enjoy your happy ride! :D
 

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
Good. don't waste your time. I dont need to be treated like sh*t to get information. Just ignore my posts; better yet just place me on ignore.
 

Кто просматривает тему: (Всего: 4, Пользователи: 0, Гости: 4)