Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Regex replace in SQLite3 database
Post: Regex replace in SQLite3 database

Can someone help me with the basic structure of a Python program to do a regex replace in a SQLite3 database?
WJSwan General Coding Help 1 796 Dec-04-2023, 07:17 AM
    Thread: <b> followed by <b> before closing</b>
Post: <b> followed by <b> before closing</b>

I am trying to edit some HTML text in Python. I have an HTML file where there are sometimes a <b> tag (Bold) and before it is closed with a </b> there is another <b>, eg: <RF>...
WJSwan General Coding Help 1 778 Mar-20-2023, 01:12 PM
    Thread: Non-greedy regex
Post: Non-greedy regex

I am struggling to correctly set up a non-greedy regex to correct the following: <a href=’tw://bible.*?id=1.2.7>Gen 2:7; <a href=’tw://bible.*?id=1.2.17>Gen 2:17; 5:29 Must become: <a...
WJSwan General Coding Help 1 913 Mar-07-2023, 07:57 AM
    Thread: use of escape character in re.sub and find
Post: use of escape character in re.sub and find

Where can I find documentation so that I can learn how to use escape characters in re.sub and with find method correctly? I tend to find that I always do this by trial and error. I am never sure when...
WJSwan General Coding Help 1 910 Feb-16-2023, 04:48 AM
    Thread: using re.search
Post: RE: using re.search

Thank you, much appreciated.
WJSwan General Coding Help 3 1,036 Feb-14-2023, 10:35 AM
    Thread: using re.search
Post: using re.search

If I use the re.search method: pattern = r"\\f (.+)\\fr(.+)\\fk(.+)\\ft(.+)\\\+xt(.+)\\\+xt\*(.+)\\f\*" fnote=re.search(pattern, irec) print(fnote)I get: <re.Match object; span=(...
WJSwan General Coding Help 3 1,036 Feb-14-2023, 07:05 AM
    Thread: Replace with upper(string)
Post: RE: Replace with upper(string)

(Feb-10-2023, 06:37 AM)deanhystad Wrote: Need to modify the pattern to not be greedy. https://docs.python.org/3/howto/regex.ht...non-greedy Thank you for this. It works like a charm
WJSwan General Coding Help 7 1,586 Feb-10-2023, 10:28 AM
    Thread: Replace with upper(string)
Post: RE: Replace with upper(string)

I played around myself and found that this works: text = r"Here is a \nd Word\nd* that is in upper case and \nd another\nd* one of them" def MakeUpper(text): ttxt="" while True: nd=...
WJSwan General Coding Help 7 1,586 Feb-10-2023, 10:17 AM
    Thread: Replace with upper(string)
Post: RE: Replace with upper(string)

Thank you deanhystad, There is just one small shortcoming (I admit I did not mention it!) in that if the \nd...\nd* string appears more than once, it messes it up: import re test_str = r"Here is a ...
WJSwan General Coding Help 7 1,586 Feb-10-2023, 06:14 AM
    Thread: Replace with upper(string)
Post: Replace with upper(string)

I need to find all strings like this: \nd string \nd* where string is any alphabetic string, eg. [A-z]+ I then need to replace it by upper(string) For instance: "Here is a \nd Word \nd* in upper ...
WJSwan General Coding Help 7 1,586 Feb-08-2023, 05:25 AM
    Thread: Regex pattern match
Post: RE: Regex pattern match

Thank you!
WJSwan General Coding Help 2 1,254 Feb-07-2023, 04:52 AM
    Thread: Regex pattern match
Post: Regex pattern match

I am trying to match all characters between "\x" and "\xk" for instance: in the string "\x - \xo 2:2 \xk". I set my pattern as: pattern = "\\x.+\\xk" replaceWith = "<b>" irec=re.sub(pattern, ...
WJSwan General Coding Help 2 1,254 Feb-06-2023, 12:11 PM
    Thread: Replace based on values in a file
Post: RE: Replace based on values in a file

Here is what I tried, but it does not seem to work. # Convert import codecs import re def FixXrefs(xref): global bookname global bookno lg.write("----- Entered function\n") ins...
WJSwan Homework 2 1,511 Jan-30-2023, 09:00 AM
    Thread: Replace based on values in a file
Post: Replace based on values in a file

I have a file containing records with 4 values, eg: 1,Genesis,Gen,Gen 2,Eksodus,Eks,Exo 3,Levitikus,Lev,Lev 4,Numeri,Num,Num 5,Deuteronomium,Deut,Deu 6,Josua,Jos,Jos 7,Rigters,Rig,Jdg 8,Rut,Rut,Rth 9,...
WJSwan Homework 2 1,511 Jan-30-2023, 05:45 AM
    Thread: Error when using FIND
Post: Error when using FIND

I am trying to find a string in a text file and get an error on the first find statement. xrefstart=irec.find("\x - \xo ") if xrefstart > 0: #find the \xt ...
WJSwan General Coding Help 2 897 Jan-27-2023, 05:36 AM
    Thread: String replacement in DB
Post: String replacement in DB

I have two SQLite3 databases each with one table: Database: MyModule.db has a table "content" CREATE TABLE "content" ( "topic_id" integer, "data" BLOB, "data2" blob, PRIMARY...
WJSwan General Coding Help 0 752 Dec-28-2022, 05:31 AM
    Thread: QlistWidget - item already exists
Post: RE: QlistWidget - item already exists

I managed to get it done.
WJSwan General Coding Help 1 2,031 Jul-08-2020, 08:16 AM
    Thread: QlistWidget - item already exists
Post: QlistWidget - item already exists

In a QListWidget, how do I check if a specific item already exists? It needs to match exactly. I do not understand how to use MatchFlags correctly.
WJSwan General Coding Help 1 2,031 Jul-07-2020, 02:40 PM
    Thread: Validating user input
Post: Validating user input

I am new to Python and do not know how to do the following: I have an input statement asking the user to enter 4 values. I then validate these values and if anyone fails the validation, I need the us...
WJSwan General Coding Help 2 2,125 Jul-06-2020, 07:03 AM
    Thread: Limiting valid values for a variable in a class
Post: RE: Limiting valid values for a variable in a clas...

Thank you!!
WJSwan General Coding Help 5 3,622 Jul-06-2020, 06:52 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020