P
P
PressOff2020-06-26 18:13:12
excel
PressOff, 2020-06-26 18:13:12

How to use regular expressions in Excel?

Good day!
The task is to divide one cell into four.
Here is the whole cell:
5ef60f4432182282939513.png

Here is the desired result:
5ef60ffb2a185341277101.png

What expressions should be written in these cells?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Grigory Boev, 2020-06-26
@ProgrammerForever

There are 2 options - look for specific characters using SEARCH () and slicing the string using MID () or use regular expressions

Public Function RegExpExtract(sText As Variant, Pattern As String) As Variant
    On Error GoTo ErrHandl
    Text = CStr(sText)
    Dim regex As New RegExp ' создаем экземпляр RegExp
    regex.Pattern = Pattern
    regex.Global = False
    If regex.test(Text) Then
        Set matches = regex.Execute(Text)
        RegExpExtract = matches.Item(0).SubMatches(0)
        Exit Function
    End If
ErrHandl:
    RegExpExtract = ""
    'RegExpExtract = "#" & err.Number & "> " & err.Description
End Function

Works similar to REGEXEXTRACT () in Google Sheets

E
Edward, 2020-06-26
@IS-Builder

press off

interested in regular expression formulas for each cell.

Функции регулярных выражений в Excel

A
Aleksej2020, 2020-07-02
@Aleksej2020

For each cell, depending on the characters:
=MID(cell;SEARCH("City: "+n;cell);SEARCH("Name/store:";cell)-SEARCH("City: "+t;cell)+n )
Cell - a link to the cell,
+ n - signs will be determined by selection, if without complicating the formula)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question