regular expression to fetch the specific patternHow to merge two dictionaries in a single expression?What is the best regular expression to check if a string is a valid URL?Is there a regular expression to detect a valid regular expression?jQuery selector regular expressionsHow to validate an email address using a regular expression?Regular Expression for alphanumeric and underscoresRegular expression to match a line that doesn't contain a wordHow do you access the matched groups in a JavaScript regular expression?Regular Expressions: Is there an AND operator?How do you use a variable in a regular expression?

Two researchers want to work on the same extension to my paper. Who to help?

How are one-time password generators like Google Authenticator different from having two passwords?

Size of a folder with du

Was there ever any real use for a 6800-based Apple I?

As programers say: Strive to be lazy

What does i386 mean on macOS Mojave?

Is it a bad idea to replace pull-up resistors with hard pull-ups?

When a land becomes a creature, is it untapped?

Why was Endgame Thanos so different than Infinity War Thanos?

Meaning of「〜てみたいと思います」

Exclude loop* snap devices from lsblk output?

SSD - Disk is OK, one bad sector

What is the significance of 4200 BCE in context of farming replacing foraging in Europe?

Why is “Ich wusste, dass aus dir mal was wird” grammitally correct?

Why was the Ancient One so hesitant to teach Dr. Strange the art of sorcery?

How to cope with regret and shame about not fully utilizing opportunities during PhD?

Run script for 10 times until meets the condition, but break the loop if it meets the condition during iteration

Why does the Earth follow an elliptical trajectory rather than a parabolic one?

Is there a spell to protect inanimate objects?

Does Lawful Interception of 4G / the proposed 5G provide a back door for hackers as well?

What are the components of a legend (in the sense of a tale, not a figure legend)?

Should these notes be played as a chord or one after another?

Front derailleur hard to move due to gear cable angle

On studying Computer Science vs. Software Engineering to become a proficient coder



regular expression to fetch the specific pattern


How to merge two dictionaries in a single expression?What is the best regular expression to check if a string is a valid URL?Is there a regular expression to detect a valid regular expression?jQuery selector regular expressionsHow to validate an email address using a regular expression?Regular Expression for alphanumeric and underscoresRegular expression to match a line that doesn't contain a wordHow do you access the matched groups in a JavaScript regular expression?Regular Expressions: Is there an AND operator?How do you use a variable in a regular expression?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I need to fetch the specific rule from the filter list that how many rules are there in with this category.



I have tried to fetch this type of rule from the filter list. The rule pattern is as follows




" /example.com $script,domain=example.com "




and the second exception rule is




"@@/example.com $script,domain=example.com "




third rule with domain anchor is




"||example.com




whereas fourth rule with anchor and domain tag is




"||jizz.best^$popup,domain=vivo.sx




and the fifth one is




"@@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com




6th one with domain restriction is as follows




"example.com###examplebanner




7th without domain restriction is




"###examplebanner




8th is exeptional with element hidding




example.com#@##examplebanner




These are different categories of rules I have to fetch separately



a=open('1-19-16anti-adblock-killer-filters.txt','r')
text=a.read()
line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with :line")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


i am trying now to fetch 5th , 6th ,7th and 8th rule . Your response will be appreciated, thanks.










share|improve this question
























  • kindly guide me regarding this @blhsing

    – kashifbilal kashi
    Mar 23 at 12:04

















0















I need to fetch the specific rule from the filter list that how many rules are there in with this category.



I have tried to fetch this type of rule from the filter list. The rule pattern is as follows




" /example.com $script,domain=example.com "




and the second exception rule is




"@@/example.com $script,domain=example.com "




third rule with domain anchor is




"||example.com




whereas fourth rule with anchor and domain tag is




"||jizz.best^$popup,domain=vivo.sx




and the fifth one is




"@@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com




6th one with domain restriction is as follows




"example.com###examplebanner




7th without domain restriction is




"###examplebanner




8th is exeptional with element hidding




example.com#@##examplebanner




These are different categories of rules I have to fetch separately



a=open('1-19-16anti-adblock-killer-filters.txt','r')
text=a.read()
line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with :line")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


i am trying now to fetch 5th , 6th ,7th and 8th rule . Your response will be appreciated, thanks.










share|improve this question
























  • kindly guide me regarding this @blhsing

    – kashifbilal kashi
    Mar 23 at 12:04













0












0








0








I need to fetch the specific rule from the filter list that how many rules are there in with this category.



I have tried to fetch this type of rule from the filter list. The rule pattern is as follows




" /example.com $script,domain=example.com "




and the second exception rule is




"@@/example.com $script,domain=example.com "




third rule with domain anchor is




"||example.com




whereas fourth rule with anchor and domain tag is




"||jizz.best^$popup,domain=vivo.sx




and the fifth one is




"@@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com




6th one with domain restriction is as follows




"example.com###examplebanner




7th without domain restriction is




"###examplebanner




8th is exeptional with element hidding




example.com#@##examplebanner




These are different categories of rules I have to fetch separately



a=open('1-19-16anti-adblock-killer-filters.txt','r')
text=a.read()
line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with :line")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


i am trying now to fetch 5th , 6th ,7th and 8th rule . Your response will be appreciated, thanks.










share|improve this question
















I need to fetch the specific rule from the filter list that how many rules are there in with this category.



I have tried to fetch this type of rule from the filter list. The rule pattern is as follows




" /example.com $script,domain=example.com "




and the second exception rule is




"@@/example.com $script,domain=example.com "




third rule with domain anchor is




"||example.com




whereas fourth rule with anchor and domain tag is




"||jizz.best^$popup,domain=vivo.sx




and the fifth one is




"@@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com




6th one with domain restriction is as follows




"example.com###examplebanner




7th without domain restriction is




"###examplebanner




8th is exeptional with element hidding




example.com#@##examplebanner




These are different categories of rules I have to fetch separately



a=open('1-19-16anti-adblock-killer-filters.txt','r')
text=a.read()
line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with :line")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


i am trying now to fetch 5th , 6th ,7th and 8th rule . Your response will be appreciated, thanks.







python regex filter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 16:04







kashifbilal kashi

















asked Mar 23 at 12:01









kashifbilal kashikashifbilal kashi

167




167












  • kindly guide me regarding this @blhsing

    – kashifbilal kashi
    Mar 23 at 12:04

















  • kindly guide me regarding this @blhsing

    – kashifbilal kashi
    Mar 23 at 12:04
















kindly guide me regarding this @blhsing

– kashifbilal kashi
Mar 23 at 12:04





kindly guide me regarding this @blhsing

– kashifbilal kashi
Mar 23 at 12:04












1 Answer
1






active

oldest

votes


















1














Your regex does not fit the , before domain:



"/[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+domain="
# ^^^^^^^^^^^^ no , allowed


You can also simplify this a lot:



with open("easylist.txt") as f: 
print('There are total Rule With Domain tag are =', f.read().count(",domain="))


should give you your answer of how often ',domain=' occures. If your file is big, you can also count linewise:



domain_rule_count = 0
with open("easylist.txt") as f:
for line in f:
domain_rule_count += 1 if ",domain=" in line else 0



Edit after question in comment:
You simply test for what you want:



text = """ some text
/example.com $script,domain=example.com
@@/example.com $script,domain=example.com
||example.com
||jizz.best^$popup,domain=vivo.sx
"""

line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with 'line'")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


Output:



No idea what to do with ' some text'
2pipes_no_group 1
2pipes_with_group 1
2@_with_group 1
line_with_domain 1





share|improve this answer

























  • i am trying to count rule catagory wise like some rule are with domain anchor "||" and domain tag "domain=" where as some rule are with only domain tag "domain=" like in the above example and some are with only domain anchor so i am divinding these rule in three types 1. ||example.com 2. @@||shoqolate.com^$script,domain=games.pch.com and 3. ||padsdel.com^$domain=oload.tv|openload.co|streamango.com 4. /example.com $script,domain=example.com so what patteren will be for these type of rule ? i'll be thakful to you if make it for me @Patrick

    – kashifbilal kashi
    Mar 23 at 12:34











  • @kash If you want to exclude some lines - test for what you want to exclude: domain_rule_count += 1 if (",domain=" in line and not line.startswith("||") ) else 0 ... your description does not make much sense to me - maybe add more example data by editing your question. Comments are notoriously bad for formatting text.

    – Patrick Artner
    Mar 23 at 12:36












  • i have updated the question , kindly review it @Patrick

    – kashifbilal kashi
    Mar 23 at 12:52












  • its realy helpful thanks a lot @patrick

    – kashifbilal kashi
    Mar 23 at 13:33











  • i have updated the question . kindly update your code for the last time because new rule are added here and i am facing problem particularly with 5th and 8th . I m trying to fetch rule with only domain tag like " /example.com $script,domain=example.com " " @@/example.com $script,domain=example.com "but it also count @@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com

    – kashifbilal kashi
    Mar 23 at 16:09












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313522%2fregular-expression-to-fetch-the-specific-pattern%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Your regex does not fit the , before domain:



"/[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+domain="
# ^^^^^^^^^^^^ no , allowed


You can also simplify this a lot:



with open("easylist.txt") as f: 
print('There are total Rule With Domain tag are =', f.read().count(",domain="))


should give you your answer of how often ',domain=' occures. If your file is big, you can also count linewise:



domain_rule_count = 0
with open("easylist.txt") as f:
for line in f:
domain_rule_count += 1 if ",domain=" in line else 0



Edit after question in comment:
You simply test for what you want:



text = """ some text
/example.com $script,domain=example.com
@@/example.com $script,domain=example.com
||example.com
||jizz.best^$popup,domain=vivo.sx
"""

line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with 'line'")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


Output:



No idea what to do with ' some text'
2pipes_no_group 1
2pipes_with_group 1
2@_with_group 1
line_with_domain 1





share|improve this answer

























  • i am trying to count rule catagory wise like some rule are with domain anchor "||" and domain tag "domain=" where as some rule are with only domain tag "domain=" like in the above example and some are with only domain anchor so i am divinding these rule in three types 1. ||example.com 2. @@||shoqolate.com^$script,domain=games.pch.com and 3. ||padsdel.com^$domain=oload.tv|openload.co|streamango.com 4. /example.com $script,domain=example.com so what patteren will be for these type of rule ? i'll be thakful to you if make it for me @Patrick

    – kashifbilal kashi
    Mar 23 at 12:34











  • @kash If you want to exclude some lines - test for what you want to exclude: domain_rule_count += 1 if (",domain=" in line and not line.startswith("||") ) else 0 ... your description does not make much sense to me - maybe add more example data by editing your question. Comments are notoriously bad for formatting text.

    – Patrick Artner
    Mar 23 at 12:36












  • i have updated the question , kindly review it @Patrick

    – kashifbilal kashi
    Mar 23 at 12:52












  • its realy helpful thanks a lot @patrick

    – kashifbilal kashi
    Mar 23 at 13:33











  • i have updated the question . kindly update your code for the last time because new rule are added here and i am facing problem particularly with 5th and 8th . I m trying to fetch rule with only domain tag like " /example.com $script,domain=example.com " " @@/example.com $script,domain=example.com "but it also count @@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com

    – kashifbilal kashi
    Mar 23 at 16:09
















1














Your regex does not fit the , before domain:



"/[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+domain="
# ^^^^^^^^^^^^ no , allowed


You can also simplify this a lot:



with open("easylist.txt") as f: 
print('There are total Rule With Domain tag are =', f.read().count(",domain="))


should give you your answer of how often ',domain=' occures. If your file is big, you can also count linewise:



domain_rule_count = 0
with open("easylist.txt") as f:
for line in f:
domain_rule_count += 1 if ",domain=" in line else 0



Edit after question in comment:
You simply test for what you want:



text = """ some text
/example.com $script,domain=example.com
@@/example.com $script,domain=example.com
||example.com
||jizz.best^$popup,domain=vivo.sx
"""

line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with 'line'")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


Output:



No idea what to do with ' some text'
2pipes_no_group 1
2pipes_with_group 1
2@_with_group 1
line_with_domain 1





share|improve this answer

























  • i am trying to count rule catagory wise like some rule are with domain anchor "||" and domain tag "domain=" where as some rule are with only domain tag "domain=" like in the above example and some are with only domain anchor so i am divinding these rule in three types 1. ||example.com 2. @@||shoqolate.com^$script,domain=games.pch.com and 3. ||padsdel.com^$domain=oload.tv|openload.co|streamango.com 4. /example.com $script,domain=example.com so what patteren will be for these type of rule ? i'll be thakful to you if make it for me @Patrick

    – kashifbilal kashi
    Mar 23 at 12:34











  • @kash If you want to exclude some lines - test for what you want to exclude: domain_rule_count += 1 if (",domain=" in line and not line.startswith("||") ) else 0 ... your description does not make much sense to me - maybe add more example data by editing your question. Comments are notoriously bad for formatting text.

    – Patrick Artner
    Mar 23 at 12:36












  • i have updated the question , kindly review it @Patrick

    – kashifbilal kashi
    Mar 23 at 12:52












  • its realy helpful thanks a lot @patrick

    – kashifbilal kashi
    Mar 23 at 13:33











  • i have updated the question . kindly update your code for the last time because new rule are added here and i am facing problem particularly with 5th and 8th . I m trying to fetch rule with only domain tag like " /example.com $script,domain=example.com " " @@/example.com $script,domain=example.com "but it also count @@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com

    – kashifbilal kashi
    Mar 23 at 16:09














1












1








1







Your regex does not fit the , before domain:



"/[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+domain="
# ^^^^^^^^^^^^ no , allowed


You can also simplify this a lot:



with open("easylist.txt") as f: 
print('There are total Rule With Domain tag are =', f.read().count(",domain="))


should give you your answer of how often ',domain=' occures. If your file is big, you can also count linewise:



domain_rule_count = 0
with open("easylist.txt") as f:
for line in f:
domain_rule_count += 1 if ",domain=" in line else 0



Edit after question in comment:
You simply test for what you want:



text = """ some text
/example.com $script,domain=example.com
@@/example.com $script,domain=example.com
||example.com
||jizz.best^$popup,domain=vivo.sx
"""

line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with 'line'")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


Output:



No idea what to do with ' some text'
2pipes_no_group 1
2pipes_with_group 1
2@_with_group 1
line_with_domain 1





share|improve this answer















Your regex does not fit the , before domain:



"/[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+domain="
# ^^^^^^^^^^^^ no , allowed


You can also simplify this a lot:



with open("easylist.txt") as f: 
print('There are total Rule With Domain tag are =', f.read().count(",domain="))


should give you your answer of how often ',domain=' occures. If your file is big, you can also count linewise:



domain_rule_count = 0
with open("easylist.txt") as f:
for line in f:
domain_rule_count += 1 if ",domain=" in line else 0



Edit after question in comment:
You simply test for what you want:



text = """ some text
/example.com $script,domain=example.com
@@/example.com $script,domain=example.com
||example.com
||jizz.best^$popup,domain=vivo.sx
"""

line_starts_with_2pipes_no_domain = 0
line_starts_with_2pipes_with_domain = 0
line_starts_with_2ats_with_domain = 0
line_with_domain = 0

for line in text.split("n"):
if line.startswith("||"):
if ",domain" in line:
line_starts_with_2pipes_with_domain += 1
else:
line_starts_with_2pipes_no_domain += 1
elif line.startswith("@@") and ",domain" in line:
line_starts_with_2ats_with_domain += 1
elif ",domain" in line:
line_with_domain += 1
elif line.strip():
print(f"No idea what to do with 'line'")

print("2pipes_no_group", line_starts_with_2pipes_no_domain )
print("2pipes_with_group", line_starts_with_2pipes_with_domain )
print("2@_with_group", line_starts_with_2ats_with_domain )
print("line_with_domain", line_with_domain)


Output:



No idea what to do with ' some text'
2pipes_no_group 1
2pipes_with_group 1
2@_with_group 1
line_with_domain 1






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 23 at 13:11

























answered Mar 23 at 12:08









Patrick ArtnerPatrick Artner

27.6k62545




27.6k62545












  • i am trying to count rule catagory wise like some rule are with domain anchor "||" and domain tag "domain=" where as some rule are with only domain tag "domain=" like in the above example and some are with only domain anchor so i am divinding these rule in three types 1. ||example.com 2. @@||shoqolate.com^$script,domain=games.pch.com and 3. ||padsdel.com^$domain=oload.tv|openload.co|streamango.com 4. /example.com $script,domain=example.com so what patteren will be for these type of rule ? i'll be thakful to you if make it for me @Patrick

    – kashifbilal kashi
    Mar 23 at 12:34











  • @kash If you want to exclude some lines - test for what you want to exclude: domain_rule_count += 1 if (",domain=" in line and not line.startswith("||") ) else 0 ... your description does not make much sense to me - maybe add more example data by editing your question. Comments are notoriously bad for formatting text.

    – Patrick Artner
    Mar 23 at 12:36












  • i have updated the question , kindly review it @Patrick

    – kashifbilal kashi
    Mar 23 at 12:52












  • its realy helpful thanks a lot @patrick

    – kashifbilal kashi
    Mar 23 at 13:33











  • i have updated the question . kindly update your code for the last time because new rule are added here and i am facing problem particularly with 5th and 8th . I m trying to fetch rule with only domain tag like " /example.com $script,domain=example.com " " @@/example.com $script,domain=example.com "but it also count @@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com

    – kashifbilal kashi
    Mar 23 at 16:09


















  • i am trying to count rule catagory wise like some rule are with domain anchor "||" and domain tag "domain=" where as some rule are with only domain tag "domain=" like in the above example and some are with only domain anchor so i am divinding these rule in three types 1. ||example.com 2. @@||shoqolate.com^$script,domain=games.pch.com and 3. ||padsdel.com^$domain=oload.tv|openload.co|streamango.com 4. /example.com $script,domain=example.com so what patteren will be for these type of rule ? i'll be thakful to you if make it for me @Patrick

    – kashifbilal kashi
    Mar 23 at 12:34











  • @kash If you want to exclude some lines - test for what you want to exclude: domain_rule_count += 1 if (",domain=" in line and not line.startswith("||") ) else 0 ... your description does not make much sense to me - maybe add more example data by editing your question. Comments are notoriously bad for formatting text.

    – Patrick Artner
    Mar 23 at 12:36












  • i have updated the question , kindly review it @Patrick

    – kashifbilal kashi
    Mar 23 at 12:52












  • its realy helpful thanks a lot @patrick

    – kashifbilal kashi
    Mar 23 at 13:33











  • i have updated the question . kindly update your code for the last time because new rule are added here and i am facing problem particularly with 5th and 8th . I m trying to fetch rule with only domain tag like " /example.com $script,domain=example.com " " @@/example.com $script,domain=example.com "but it also count @@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com

    – kashifbilal kashi
    Mar 23 at 16:09

















i am trying to count rule catagory wise like some rule are with domain anchor "||" and domain tag "domain=" where as some rule are with only domain tag "domain=" like in the above example and some are with only domain anchor so i am divinding these rule in three types 1. ||example.com 2. @@||shoqolate.com^$script,domain=games.pch.com and 3. ||padsdel.com^$domain=oload.tv|openload.co|streamango.com 4. /example.com $script,domain=example.com so what patteren will be for these type of rule ? i'll be thakful to you if make it for me @Patrick

– kashifbilal kashi
Mar 23 at 12:34





i am trying to count rule catagory wise like some rule are with domain anchor "||" and domain tag "domain=" where as some rule are with only domain tag "domain=" like in the above example and some are with only domain anchor so i am divinding these rule in three types 1. ||example.com 2. @@||shoqolate.com^$script,domain=games.pch.com and 3. ||padsdel.com^$domain=oload.tv|openload.co|streamango.com 4. /example.com $script,domain=example.com so what patteren will be for these type of rule ? i'll be thakful to you if make it for me @Patrick

– kashifbilal kashi
Mar 23 at 12:34













@kash If you want to exclude some lines - test for what you want to exclude: domain_rule_count += 1 if (",domain=" in line and not line.startswith("||") ) else 0 ... your description does not make much sense to me - maybe add more example data by editing your question. Comments are notoriously bad for formatting text.

– Patrick Artner
Mar 23 at 12:36






@kash If you want to exclude some lines - test for what you want to exclude: domain_rule_count += 1 if (",domain=" in line and not line.startswith("||") ) else 0 ... your description does not make much sense to me - maybe add more example data by editing your question. Comments are notoriously bad for formatting text.

– Patrick Artner
Mar 23 at 12:36














i have updated the question , kindly review it @Patrick

– kashifbilal kashi
Mar 23 at 12:52






i have updated the question , kindly review it @Patrick

– kashifbilal kashi
Mar 23 at 12:52














its realy helpful thanks a lot @patrick

– kashifbilal kashi
Mar 23 at 13:33





its realy helpful thanks a lot @patrick

– kashifbilal kashi
Mar 23 at 13:33













i have updated the question . kindly update your code for the last time because new rule are added here and i am facing problem particularly with 5th and 8th . I m trying to fetch rule with only domain tag like " /example.com $script,domain=example.com " " @@/example.com $script,domain=example.com "but it also count @@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com

– kashifbilal kashi
Mar 23 at 16:09






i have updated the question . kindly update your code for the last time because new rule are added here and i am facing problem particularly with 5th and 8th . I m trying to fetch rule with only domain tag like " /example.com $script,domain=example.com " " @@/example.com $script,domain=example.com "but it also count @@||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,domain=quebeccoupongratuit.com

– kashifbilal kashi
Mar 23 at 16:09




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313522%2fregular-expression-to-fetch-the-specific-pattern%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현