href string using wild cards - href

Is it possible to use a wild card * in a file name. I have a really long image Tiff file that I want to in the href line but only look for the first 10 to 12 characters or first - in the file.

Related

Regex for values that are in between spaces

I am new to regex and having difficulty obtaining values that are caught in between spaces.
I am trying to get the values "field 1" "abc/def try" from the sameple data below just using regex
Currently im using (^.{18}\s+) to skip the first 18 characters, but am at at loss of how to do grab values with spaces between.
A1234567890 field 1 abc/def try
02021051812 12 test test 12 pass
3333G132021 no test test cancel
any help/pointers will be appreciated.
If this text has fixed-width columns, you can match and trim the column values knowing the amount of chars between start of string and the column text.
For example, this regex will work for the text you posted:
^(.*?)\s*(?<=.{19})(.*?)\s*(?<=^.{34})(.*?)\s*(?<=^.{46})
See the regex demo.
So, Column 2 starts at Position 19, Column 3 starts at Position 34 and Column 4 (end of string here) is at Position 46.
However, this regex is not that efficient, and it would be really great if the data format is fixed on the provider's side.
Given the not knowing if the data is always the same length I created the following, which will provide you with a group per column you might want to use:
^((\s{0,1}\S{1,})*)(\s{2,})((\s{0,1}\S{1,})*)(\s{2,})((\s{0,1}\S{1,})*)
Regex demo

How to extract part of a mp3 title (string) to name a new tag in mp3tag with Regex?

I'm trying to extract the specified keys of a song each included in many mp3 files, using the mp3Tag program.
The number of characters to the left of the Musical key in the mp3 filnames is constant (29 characters), so I succeeded in cutting it with the $left(x,n) function imbedded in the $regexp(x,expr,repl) function.
But my specific problem is the variable number of characters to the right of the Musical Key - since it is variable I cannot use the $right(x,n) function effectively. I tought of using the combinations of functions $len(x) and$right(x,n) to substract the Musical Key from the remaining string but can't see how to do it with a variable number of character to the right of the Musical Key.
The whole Point is to have a clean Tag column with all the keys per track (without remaning all the collection manually one by one :)).
I scanned the functions given here, but I can't see which combination of those other functions would work to cut the variable number of characters to the right of the Musical Keys:
(mp3tag function - String functions
My question:
How do I do that with other functions or a whole different simpler approach?
So far I did cut the constant 29 characters to the left of the Musical key in the mp3 filname with the help of:
Tag - Tag (Convert Wizard)
$regexp(x,expr,repl) (mp3tag function - String functions
$left(x,n) (mp3tag function - idem)
$right(x,n) (mp3tag function - idem)
For example:
Wanted result (extracted D, A, G Musical Keys in a new Keys Tag Column):
D
A
G
from filenames:
510 - Sonata for keyboard in D minor, K. 517 (L. 266).mp3
026 - Sonata for keyboard in A major, K. 26 (L. 368).mp3
031 - Sonata for keyboard in G minor, K. 31 (L. 231).mp3
1st operation Tag - Tag ($left(x,n) function):
Cut the first 29 characters
(relpaces: 031_-_Sonata_for_keyboard_in_ by blank (' ')
using the embeded $left(x,n) function in the $regexp(x,expr,repl) function:
As follows:
Used functions:
$regexp(x,expr,repl)
$left(x,n)
// Embedding of functions
$regexp(x,$left(x,n),repl)
// String assignation (parameter String in the $left(x,n) function)
$regexp(x,$left(%initialkey%,n),repl)
// Statement of the numbers of caracters to cut/void from 1st to the Musical Key's character (D, A, G, etc.)(same number for all the mp3 files (29 characters))
$regexp(%initialkey%,$left(%initialkey%,29),' ')
// String assignation (parameter String in the $regexp(x,expr,repl) function)
$regexp(%initialkey%,$left(%initialkey%,29),repl)
// Voiding/cutting replacing with no character parameter of regexp function
(' ' voiding string replacement parameter in the $regexp(x,expr,repl) function)
$regexp(%initialkey%,$left(%initialkey%,29),' ')
Thanks a lot for your help!
Ref. used:
Mp3Tag - Replace with regular expression
Scripting functions
Second, Third, … Occurences Of String
Extract title part for track no.
Convert Tag-Tag
Open MenuHow to Use Mp3Tag to Edit Audio Files by xephyx
I found the following simpler way using the free program Advanced Renamer
It has a cool built-in Remove function and even an amazing Javascript Script editor.
The Solution I used:
Basically:
To keep things simple and spare using a script for this operation, I inputed 100 characters to remove, starting 1 index/position after the Musical Key. I put an arbitrary 100 characters to remove as all the mp3 files titles had less than 100 characters following the Musical Key.
If for your case it has more, input 1000 :) !
Here are the pics of the process:
1st Step. Removal of the firs 29 characters
1st Step Result
2nd Step. Removal of all characters succeeding the Musical Key
2nd Step result
here the guide of Advanced Renamer other cool Renaming methods:
Renaming Methods

Is there any possible way to get the last value performed in python split function

For Example,
i have a following txt file in my system
My name is pavithran
I am from chennai
Hobbies are reading
I love cricket
In that, I just want to print only the last word of that each file.
My output will be like:
pavithran
chennai
reading
cricket
I know to perform this, read each line using for loop
and use split function to split the word and print that word you want at certain location
But , i want a last word from each line not on 3rd and 4 th location Like that..How can achieve that?
Easy
you need to use
line.split(" ")[-1]
for each line to get the last word
PS comments are not for posting answers

Reading difficult text file in python: no spaces and split numbers in lines

I've been stuck in how to read the following text file --> Extract of the text file I would like to read <-- in Python. This file contains 374 numbers per line, and in total 201 lines. However, the file has the following inconveniences:
1) Numbers are not separated by white spaces or any other delimiter.
2) The first number of each line always doesn't have the first 0 (for instance, it is written .15 instead of 0.15).
Do you have any ideas or solutions of how to read this file in Python? I had never have to deal with such as difficult text file (and I receive the text files from another person, and I cannot ask that person to save the data again).
Thank you in advance,
That looks like numbers in "scientific notation", with two-digit exponents. In your sample it looks like there's never a zero or other digit before the decimal point. Try reading them like this:
with open("file.txt") as inp:
text = inp.read()
numbers = re.findall(r"[.\d]*?D[+-]\d\d", text)
If you want to convert the number strings to floats:
values = [ float(n.replace("D", "e")) for n in numbers ]

Notepad++ find and replace with word containing first word?

I have in one file words in 2 columns and 2 word in row represent interaction.
A0AV96 P25515
A6H8V1 A4D1U5
A8YXX4 A6NCZ6
B0ZBE0 A8BBF9
B3KWQ6 B3KRK5
B4E398 A4D1N9
B6ZGU1 B3KPR3
In second file i have litle bit more information about interactors like this. Here information in every row is extendend info about word from above file.
A0AV96 RBM47_HUMAN
P25515 E2F8_HUMAN
A0JLT2 MED19_HUMAN
A1ZBR5 AKTP2_DROME
A1ZBT5 MED8_DROME
A2A3L6 TTC24_HUMAN
What i need is some way to merge or find and replace words from this two files that i get from this
A0AV96 P25515
to this
A0AV96 RBM47_HUMAN P25515 E2F8_HUMAN
For now i find solution without need for programing. There is at least 2 ways to do this. First i separate each column in single column line list file, as strand of DNA. After that i use 'Find and Replace Multiple Items At Once Software' to change this line in way i need. And after that i merge 2 lines again i 2 columns structure. Only problem is u must align properly your one column from 2 column file and column from file with additional information.