php how to extract text from between quotes and exclude quotes - string

This is the string
Content-Disposition: form-data; name="file"; filename="Resurrection Power+ Part 2 (El
Poder de la Resurrección) 20-3-2022.mp3"
I want to extract this
Resurrection Power+ Part 2 (El Poder de la Resurrección) 20-3-2022.mp3

Related

Whey am I getting a dash when I try to use Regex on a text?

After being helped, I finally managed to apply Regex on a text to try to find some patterns.
My project consists of finding dialogues in a text written in Portuguese. In Portuguese, dialogues can be found in some ways: between dashes (- ele disse que sim-), with a dash starting the dialogue (- ele disse que sim), and in between quotation marks ("eu acho que sim").
However, as words in Portuguese can also contain dashes, such as in "viu-me" or "disse-lhe", I had make a code that takes all of this information into account.
The problem I am having is that I am getting dashes when I search for the pattern in a text.
Here is my code:
text = '''
"Para muitos é mais do que isso."
Eles chegarem em casa são e salvos
Viu-se que eles não estavam lá
'''
for d in re.finditer(r'(".+")|(^\s?-\s.+\s|-)', text, re.MULTILINE):
print(d.group())
Here is the current output:
"Para muitos é mais do que isso."
-
Fantastic, the code manages to find the dialogue in quotations, but prints a dash as well. It is as if it found that it is not a dialogue, it is just a word with an embedded dash, but still shows the dash in it.
The desired output:
"Para muitos é mais do que isso."
Just put a $ sign at the last of your regex, to denote the end.
r'(".+")|(^\s?-\s.+\s|-$)'
The reason for this is because in (^\s?-\s.+\s|-) the ending with |- is incorrect. It basically tells the regex to match \s?-\s.+\s OR a dash/hyphen. Which ends up matching the hyphen in Viu-se, since there is no notion of spaces in |-.
You'll probably also need to remove the ^ in the second group because if there are dashes in the middle of a sentence, you won't catch that.
Examples:
import re
text = '''
"Para muitos é mais do que isso."
Eles chegarem em casa são e salvos
Viu-se que eles não estavam lá
hello - More text and example - and stuff
a confusing-example-with-hyphens
Here is something else
- Start with dashes -, "quote me here"
'''
rgx = r'(".+")|(\s?-\s.+\s-)'
for d in re.finditer(rgx, text, re.MULTILINE):
print(d.group())
Gets you:
"Para muitos é mais do que isso."
- More text and example -
- Start with dashes -
"quote me here"
N.B: You could also control the exact number of spaces you want to see in case you don't want to match on multiple spaces after a dash;
rgx = r'(".+")|(\s?-\s{1}.+\s{1}-)'

How to go to next line in Dialogflow responses

enter image description here
[
I want to add a new line after "the following things" as \n or other things are not working
]2
here you've used Dialogflow's web demo integration option which DOESN'T support multiple messages(lines) per response. This integration only supports single text responses.
You can use DialogFlow messenger integration if you want to add multiple messages.
To make a line break in the 'Text Response' sector just press 'Shift + Enter'.
Para realizar un salto de linea en el sector de 'Text Response' solo hay que presionar 'Shift + Enter'

Why CHOOSE FUNCTION nested does not work without apparent visible error in MS Excel?**

I have a comments in cell F4 from a data base in HTML and looks like this (in spanish)
<b>[2020-02-04 12:15:45]:</b> Se aguarda la llegada de materiales. Hoy llega el material a sitio. Mientras, estamos realizando auditoria en BH715.
<br>
<b>[2020-01-31 15:16:58]:</b> COMENTARIO ASIGNACION: Se reasigna a otro supervisor por vacaciones.
So... I want to clean the text deleting (html tags):
"" , ":", ""
and the result will be:
[2020-02-04 12:15:45] Se aguarda la llegada de materiales. Hoy llega
el material a sitio. Mientras, estamos realizando auditoria en BH715.
[2020-01-31 15:16:58] COMENTARIO ASIGNACION: Se reasigna a otro
supervisor por vacaciones.
The two functions nested are using:
=SUBSTITUTE(F4;CHOOSE({1\2\3};"<b>";":</b>";"<br>");"")
But, only work the first number {1... of the range.
The rest of the number it doesn't work.
official Help here:
https://support.office.com/en-us/article/use-array-constants-in-array-formulas-477443ea-5e71-4242-877d-fcae47454eb8
any advice about that ?
I am using Office 2019/265 the delimiter are semicolons in my case.
thanks a lot.

How change the file in every turn of loop

I'm new at vba and I'm trying to create a form in excel with removable lists with items taken from another excel book which contains the items I need for the list.
At the same time as I want to change the label values dynamically I made a loop For Next which change the value of the label in every turn.
I need to say before you see the code that I changed the labels name to start at 0 instead 1 so my 1st label is called label0 and not label1, I made this because I created an array with the names I need for labels.
I tried to do this:
Private Sub UserForm_Initialize()
'Declarando variables
Dim file As Workbook 'variable que contiene el libro con la tabla de los archivos
Dim var As Long 'variable que para el bucle for
Dim i As Long 'variable para el bucle for
Dim label As Variant
'Creamos una array que contenga los nombres posibles de label
label = Array("Dirección", "Empresa", "Area/Planta del suceso")
'Asignamos los valores para las variables de departamentos y empresas que abrirán los respectivos archivos que se encuentran en la ruta especificada
Set file = Workbooks.Open("C:\Users\se72497\Desktop\Departamentos.xlsx")
For var = 0 To 2
'Asigna el nombre a las etiquetas
Controls("label" & var).Caption = label(var)
'Bucle que recorre cada una de las líneas que existen en la tabla de DEPARTAMENTOS y se añaden a la lista desplegable que se especifica
For i = 2 To file.Sheets("Hoja1").Range("C2").End(xlDown).Row
direccion.AddItem file.Sheets("Hoja1").Cells(i, 3).Value
Next i
Next
file.Close
End Sub
I'm trying the variable file change every time the loop returns to the For var because when label2.caption is equal to label(2) for example needs another file than when it is label1.caption=label(0) I dont know if create another array with the files path, i suppose I can do that but if anyone know another way please let mw know.

Getting attachment in vb.net from gmail

Here's my code to retrieve attachment from Gmail message
Dim attachPart As MessagePartBody = myGMailService.Users.Messages.Attachments.Get(ProfileUsager.GoogleAccountUserName, ID, attachmentID).Execute()
Dim fileByteArray() As Byte = Convert.FromBase64String(attachPart.Data())
My problem is Convert.FromBase64String, this return:
L'entrée n'est pas une chaîne Base 64 valide, car elle contient un caractère non-Base 64, plus de deux caractères de remplissage ou un caractère non conforme parmi les caractères de remplissage.
How I can resolve this? This code is a code block I found on Google API doc.

Resources