Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by theideabulb
at 2024-07-10 07:51:00
Point:500 Replies:9 POST_ID:828948USER_ID:11847
Topic:
Regular Expressions;;
I am looking for regex to help remove a section of text. Here is the HTML
<p class="online-instore-icon online NSFS"> <span class="screen-reader-only">Available </span> Not sold in stores</p><p class="online-instore-icon online NSFS"> <span class="screen-reader-only">Available </span> Not sold in stores</p><p class="online-instore-icon online NSFS"> <span class="screen-reader-only">Available </span> Sold in stores</p><p class="online-instore-icon online NSFS"> <span class="screen-reader-only">Available </span> Sold in stores</p> 1:2:3:4:5:6:7:8:9:10:11:12:
This produces text that looks like this:
Available Not sold in storesAvailable Sold in storesAvailable Sold in storesAvailable Not sold in storesAvailable Sold in stores 1:2:3:4:5:
I basically need to remove the word 'Available'
In the end it should really just be this.
Not sold in storesSold in storesSold in storesNot sold in storesSold in stores 1:2:3:4:5:
Expert: duncanb7 replied at 2024-07-10 10:10:24
Thanks for your points
Have a nice day
Duncan
Have a nice day
Duncan
Author: theideabulb replied at 2024-07-10 10:01:19
Thank you
Assisted Solution
Expert: duncanb7 replied at 2024-07-10 09:49:18
250 points EXCELLENT
you need this regex for whole html page(not just one span tag and classname), Right ?
/(<span class="screen-reader-only">Available(.*)</span>)/is
And
/(<span class="screen-reader-only">Sale Price(.*)</span>)/is
Duncan
/(<span class="screen-reader-only">Available(.*)</span>)/is
And
/(<span class="screen-reader-only">Sale Price(.*)</span>)/is
Duncan
Accepted Solution
Expert: ozo replied at 2024-07-10 08:55:26
250 points EXCELLENT
#!/usr/bin/perl
$_=<<END;
<p class="online-instore-icon online NSFS">
<span class="screen-reader-only">Available </span>
Not sold in stores</p>
<p class="online-instore-icon online NSFS">
<span class="screen-reader-only">Available </span>
Not sold in stores</p>
<p class="online-instore-icon online NSFS">
<span class="screen-reader-only">Available </span>
Sold in stores</p>
<p class="online-instore-icon online NSFS">
<span class="screen-reader-only">Available </span>
Sold in stores</p>
END
s#<span class="screen-reader-only">.*?</span>##g;
print;
$_=<<END;
<p class="online-instore-icon online NSFS">
<span class="screen-reader-only">Available </span>
Not sold in stores</p>
<p class="online-instore-icon online NSFS">
<span class="screen-reader-only">Available </span>
Not sold in stores</p>
<p class="online-instore-icon online NSFS">
<span class="screen-reader-only">Available </span>
Sold in stores</p>
<p class="online-instore-icon online NSFS">
<span class="screen-reader-only">Available </span>
Sold in stores</p>
END
s#<span class="screen-reader-only">.*?</span>##g;
print;
Author: theideabulb replied at 2024-07-10 08:37:48
All i need is find any type of element that has this: class="screen-reader-only"
<span class="screen-reader-only">
I see in the HTML code that there is also:
<p class="price price-label">
<strong class="screen-reader-only">
Sale Price</strong>
$24.99
</p>
I need to remove that Sale Price text as well.
So I am hoping there is a way to find these spots that have that class and remove them so I can grab the other text that is left over
<span class="screen-reader-only">
I see in the HTML code that there is also:
<p class="price price-label">
<strong class="screen-reader-only">
Sale Price</strong>
$24.99
</p>
I need to remove that Sale Price text as well.
So I am hoping there is a way to find these spots that have that class and remove them so I can grab the other text that is left over
Expert: duncanb7 replied at 2024-07-10 08:32:24
Could you explain more ?
Where or how you get html page code you attached ?
You mean javascrip regex code running on the html code, that will take out all "Available" ?
Regex is javascript code you mean or you want ?
If you write down step by step what you want that will be faster to solve your issue
Duncan
Where or how you get html page code you attached ?
You mean javascrip regex code running on the html code, that will take out all "Available" ?
Regex is javascript code you mean or you want ?
If you write down step by step what you want that will be faster to solve your issue
Duncan
Author: theideabulb replied at 2024-07-10 08:27:13
its for a scraper. The HTML that comes back is what I have up there. I would like to clear out that 'Available' section of text so that I can just grab what I need for the availability status.
Expert: duncanb7 replied at 2024-07-10 08:23:43
COuld you explain you want to do regex, In javascript or php script programming ?
Could you use CSS style to hide "Available" in html page such as follows
Could you use CSS style to hide "Available" in html page such as follows
Hope understand your question completely.If not, please point it out.
Duncan
Expert: Kimputer replied at 2024-07-10 07:57:33
Try this