Regex for specific forum [closed] - regex

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I don't really know how to use regex, and I have a task to get bulk image downloader to find a set amount of pages for example pages 1-20 to link crawl.
This is the URL:
/index.php?app=core&module=search&do=viewNewContent&period=month&userMode=&search_app=forums&sid=ceb2a9ba4039e4a06d3a6775aa735f2d&search_app_filters[forums][searchInKey]=&st=400
Its page (the st param) is incremented in +25 so the following page would be:
/index.php?app=core&module=search&do=viewNewContent&period=month&userMode=&search_app=forums&sid=ceb2a9ba4039e4a06d3a6775aa735f2d&search_app_filters[forums][searchInKey]=&st=425
How can I match and replace the page number with the next consecutive page number?

You can just capture the last digits and use whatever language you're writing in to increment that by 25:
/(\/index\.php.+?)(\d+)$/
This will give you the URL in $1 and the page number in $2 or matches[2] (however your language of choice represents the first "capture"). With that, you can increment it.
This Ruby example will do that:
matches = url.match(/(\/index\.php.+?)(\d+)$/)
page = matches[2].to_i # Convert the page number to integer
page = page + 25 # Calculate the new page number
new_url = matches[1] + (page).to_s # Merge in the new page number
That should do it for this format of URL.

Related

how to add whitespace before certain characters or words in google sheet [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a google sheet where i have long text string in each cell.
following is one of the text string
VACANCY...Test Hotels is hiring for the below position.#Job_Title : Director of a Revenue/ Revenue Manager#Hotel_Name : Signature Hotel#Job_Location : Dubai#Nationality : Selective#Experience : Mandatory hotel experience#Salary_Range : Unspecified#Benefits : Unspecified- Candidate should be currently in UAE and has relevant UAE Hotel experience.Please specify “Applying Position” in the subject line.Email CV: test#test.com#jobseekers #vacancy #Dubai #jobs #recruiters #hotels #manager #revenue
I want to add white spaces before certain words or character so it look neat . for example i want to add white space before "#", "Salary", " job location" etc.
Ho can i do that
Please be reminded that you have to escape any metacharacter
=REGEXREPLACE(A1,"(#|Salary|job location)"," $1")

Regex to use in HTML source [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need a regex to extract the number 330 on ...163&angleKreludor=330&viewID=.... This number vary from day to day...it could be an Integer with up to 3 digits, but it can be a double number like 127.57 with 2 decimal places ... so I would need to capture anything between angleKreludor= and &viewID.... Here is the complete HTML:
var swf = new SWFObject('http://images.lulaser.com/shenkuu/lunar/shenkuu_calendar_v1.swf?angleNeopia=163&angleKreludor=330&viewID=2&lang=pt', 'flash_36175654223', '550', '500', '6', '#FFFFFF');
swf.addParam('quality', 'high');
swf.addParam('scale', 'exactfit');
swf.addParam('menu', 'false');
swf.addParam('allowScriptAccess', 'always');
swf.addParam('swLiveConnect', 'true');
swf.addParam('bgcolor', 'white');
swf.write();
P.S: This is needed to use in Javascript code in Selenium IDE ... I tried in the past and Selenium IDE does not accept look-aheads nor look-behinds
You can search for digits with positive look-behind for the angleKreludor= key
(?<=angleKreludor=)(\d+)
DEMO
For JavaScript use non-captuinrg group
(?:angleKreludor=)(\d+)
var s = 'http://images.lulaser.com/shenkuu/lunar/shenkuu_calendar_v1.swf?angleNeopia=163&angleKreludor=330&viewID=2&lang=pt';
var nr = s.match(/(?:angleKreludor=)(\d+)/);
console.log(nr[1]);
DEMO

Using Regex to separate Asian market numerical stock tickers [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Pulling some trading data and having issues using regex to separate tickers and percentage of holding
Inputs
"94324.13%"
"007007.13%"
"0354202.91%"
Desired Output
"9432|4.13%" (ticker is 4 numbers)
"00700|7.13%" (ticker is 5 numbers)
"035420|2.91%" (ticker is 6 numbers)
Main issue is that the number of digits the ticker is may vary anywhere from 4-6 digits.
With the given information it is not possible to have a 100% accurate split of the two parts. For instance:
123410.05%
... could split in either of the following two:
1234|10.05%
12341|0.05%
And if percentages might not have a zero before the decimal point, then this would also be a possible split:
123410|.05%
The following regex replace will assume the percentage has one digit before the decimal point, and possibly a minus sign:
Find:
/^(\d{4,6})(\-?\d.*)$/gm
Replace:
\1|\2
See it on regex101.com.
I'd like to try this regex
(\d{4,6})(\d+\.\d{1,2}%)
Here is full demo:
Python:
data = "007007.13%"
rx = re.compile(r"(\d{4,6})(\d+\.\d{1,2}%)")
formated_text = rx.sub(r'\1|\2', data)
print formated_text
#it will print
00700|7.13%
You can look demo in python here
Javascript:
var re = /(\d{4,6})(\d+\.\d{1,2}%)/g;
var str = '"007007.13%"';
var subst = '$1|$2';
var result = str.replace(re, subs);
Demo in Javascript

Can I insert variables in Regular Expression? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I want to use regex so as to obtain specific information from the text and I give an example with a semi-pseudocode ~ you can also reply me with semi-pseudocode:
list=["orange","green","grey"]
text= "The Orange is orange"
for word in list:
if word == re.compile(r'word, text):
capture Orange in order to have the noun
Beware! My question focuses whether there is a possibility to use variables (as word up above) so as to make a loop and see if there are equal words in an text based on a list.
Do not focus on how to capture the Orange.
I think Biffen has the right idea, you're in a world of pain if you're using this for POS tagging. Anyway, this allows you to match words in your text variable
for word in list:
if word in text:
# Do what you want with word
If you wanted to use regex then you can build patterns from strings, use parentheses to capture. Then use group() to access captured patterns
for word in list:
pattern = re.compile(".*(" + word + ").*")
m = re.match(pattern, text)
if m:
print(m.group(1))

I need regular expression to get substring [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Started transaction at 10.12.2014 16:11:02 +02:00
UPDATE [dbo].[Urun]
SET [Ad] = #0, [Kategori] = #1
WHERE ([Id] = #2)
-- #0: 'Erkan' (Type = String, Size = 75)
-- #1: 'Karabulut' (Type = String, Size = 50)
-- #2: '1' (Type = String, Size = 25)
-- Executing asynchronously at 10.12.2014 16:11:02 +02:00
-- Completed in 4 ms with result: 1
Committed transaction at 10.12.2014 16:11:02 +02:00
That is my String . I need substring first after [dbo]. means ı need table name and the second datetime.I need regex for both them.
Output
"Urun" and "10.12.2014 16:11:02 +02:00"
Thanks for help...
Use the below regex and get the strings you want from group index 1 and 2.
(?s)\[dbo\].*?\[([^\]]*)\].*?\d{2}\.\d{2}\.\d{4}\s+\d{2}:\d{2}:\d{2}.*?\b(\d{2}\.\d{4}\s+\d{2}:\d{2}:\d{2}\s+\S+)
DEMO
Added an alernative because i don't know which date and time you mean.
(?s)\[dbo\].*?\[([^\]]*)\].*?\b(\d{2}\.\d{2}\.\d{4}\s+\d{2}:\d{2}:\d{2}\s+\S+)
DEMO
(?s) Dotall modifier which makes dot in your regex to match even line breaks.