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.
Related
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 3 years ago.
Improve this question
Data:
BUY 2 FOR 5(STORES)
BUY 2 FOR 10(STORES)
What I tried:
regexp_extract(DATA, '.*? (\\d+) .*$', 2)
Desired result:
5
10
Like this:
regexp_extract(DATA, '^[^0-9]+?\\d+[^0-9]+?(\\d+)', 1);
or
regexp_extract(DATA, '^\\D+?\\d+\\D+?(\\d+)', 1);
Regex means: one or more Non-digits at the beginning, one of more digits, one or more non-digits, and finally the capturing group of digits, you need to extract the group number one.
One more solution is to split string by non-didits and take 2nd element:
select split(DATA, '[^0-9]+')[2];
Or even simpler:
select split(DATA, '\\D+')[2]; --\\D+ means one or more non-digits
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 5 years ago.
Improve this question
Which expression should I use to identify the number of hydrogen atoms in a chemical formula?
For example:
C40H51N11O19 - 51 hydrogens
C2HO - 1 hydrogen
CO2 - no hydrogens (empty)
Any suggestions?
Thanks!
Cheers!
You can start using this regex :
H\d*
H -> match literaly the H caracter
d* -> match 0 to N time a digit
see exemple and try yourself other regex at :
https://regex101.com/r/vdvH8S/2
But regex wont convert for you the result, regex only do lookup.
You need to process your result saying :
H with a number : extract the number
only H : 1
no match : 0
A Regex Expression that will match H with follwowing digits would be:
/H(\d+)/g
The 'H' is a literal charecter match to the H in the given chemical
formula
() declares a capture group, so you cna then grab the captured group without the H in whatever programming language you are using
\d will match any digit along with the + modifier that matches 1 or more
There is no catch all scenarios here, you might be best using something other than a 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.
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
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))