<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fields extraction from TXT file with fixed position varrying event formats in each line in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396443#M115122</link>
    <description>&lt;P&gt;OK, so you told us where the field breaks are, but not the field names.  And you use &lt;CODE&gt;(?P&amp;lt;name&amp;gt;)&lt;/CODE&gt; variation so it ate you field names (do not use the &lt;CODE&gt;P&lt;/CODE&gt;).&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jul 2019 03:12:35 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-07-15T03:12:35Z</dc:date>
    <item>
      <title>Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396438#M115117</link>
      <description>&lt;P&gt;I need to monitor a text file.&lt;BR /&gt;
Each line in this file is considered an event.&lt;BR /&gt;
There are three different types of event formats in this file. Formats are called format 4, format 6 and format 8. They are all fixed position.&lt;/P&gt;

&lt;P&gt;What I need is a RegEx or any better solution to extract fields in a way that:&lt;BR /&gt;
- If event entry matches with format 4, then extract those fields accordingly as labelled. If not then look for format 6.&lt;BR /&gt;
- If event entry matches with format 6, then extract those fields accordingly as labelled. If not then look for format 8.&lt;BR /&gt;
- If event entry matches with format 8, then extract those fields accordingly as labelled.&lt;/P&gt;

&lt;P&gt;Since all three formats are fixed position so event entry will definitely match one of the three format above as per our requirements. Please notice that field 1-5 are same in each format. Change starts happening beginning from field 6 and onwards. Look like I need a solution with lookahead or if-then-else in RegEx.&lt;/P&gt;

&lt;P&gt;We used below for format 4 and it works fine. now challenge is to do conditional to have it check and extract for format 6 and format 8.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sample sourcetype=SAMPLE_CODE4 

| rex field=_raw "(?ms)^.{90}(?P.{1})" offset_field=_extracted_fields_bounds

| rex field=_raw "^.{17}(?P.{1})" offset_field=_extracted_fields_bounds0

| rex field=_raw "^.{0}(?P.{1})" offset_field=_extracted_fields_bounds1

| rex field=_raw "^.{59}(?P.{1})" offset_field=_extracted_fields_bounds2

| rex field=_raw "^.{12}(?P.{5})" offset_field=_extracted_fields_bounds3

| rex field=_raw "^.{60}(?P.{1})" offset_field=_extracted_fields_bounds4

| rex field=_raw "^.{2}(?P.{10})" offset_field=_extracted_fields_bounds5

| rex field=_raw "^.{61}(?P.{2})" offset_field=_extracted_fields_bounds6

| rex field=_raw "^.{77}(?P.{3})" offset_field=_extracted_fields_bounds7

| rex field=_raw "^.{1}(?P.{1})" offset_field=_extracted_fields_bounds8

| rex field=_raw "^.{63}(?P.{14})" offset_field=_extracted_fields_bounds9

| rex field=_raw "^.{80}(?P.{10})" offset_field=_extracted_fields_bounds10

| rex field=_raw "^.{18}(?P.{41})" offset_field=_extracted_fields_bounds11

| head 1000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See attached file. I need both search time extractions as well as configuring method of extraction in the config file as needed. Thanks in advance!!!!!&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7359i26412F397A7E5317/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Addendum:&lt;/STRONG&gt;&lt;BR /&gt;
Thanks a lot for prompt feedbacks. I was doing some more samples, position fixing for spotted issues and slightly adjusting regex for that so thats why responding a bit late. Below is additonal FIXED test data and regex. I need below regex broken down into three formats so I can use it in direct search for testing pls. I have tried it on &lt;A href="http://www.regex101.com"&gt;www.regex101.com&lt;/A&gt; and it is matching and breaking down good now. Please check.&lt;/P&gt;

&lt;P&gt;Now when I try to upload this file for one time monitoring for testing, I have only two options from UI. Either to identify each line as an EVent OR to user RegEx. When I use 1st method, it does not allow me to use below RegEx to extract fields, however, it breaks each line as an even which is good. If I use the second method, It puts all sample data together and not extract the fields nor separate each event by each line.&lt;/P&gt;

&lt;P&gt;I need below RegEx to be broken down into 3 for 3 formats, 4, 6 and 8 like @woodcock did in SPL so I can test it out there with sample data as you did please. You can do only first couple rows separated with ::: and we will take care of the rest. Thanks in advance&lt;/P&gt;

&lt;P&gt;RegEx:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?J)^(?&amp;lt;servicecenterCode&amp;gt;.)(?&amp;lt;sinonmode&amp;gt;.)(?&amp;lt;employeeId&amp;gt;.{10})(?&amp;lt;eventCode&amp;gt;.{5})(?&amp;lt;formatCode&amp;gt;4(?&amp;lt;variabledata&amp;gt;.{41})(?&amp;lt;commandcodeDefiner&amp;gt;.)(?&amp;lt;hitIndicator&amp;gt;.)(?&amp;lt;errorCode&amp;gt;..)(?&amp;lt;recordDate&amp;gt;.{14})(?&amp;lt;terminalId&amp;gt;.{4})(?&amp;lt;employeeNo&amp;gt;.{9})(?&amp;lt;servicecenterAccess&amp;gt;.)|6(?&amp;lt;customerId&amp;gt;.{9})(?&amp;lt;fileSourceCode&amp;gt;.)(?&amp;lt;customerIdType&amp;gt;.)(?&amp;lt;variabledata&amp;gt;.{30})(?&amp;lt;codeDefiner&amp;gt;.)(?&amp;lt;hitIndicator&amp;gt;.)(?&amp;lt;errorCode&amp;gt;..)(?&amp;lt;recordDate&amp;gt;.{14})(?&amp;lt;terminalId&amp;gt;.{4})(?&amp;lt;employeeId&amp;gt;.{9})(?&amp;lt;servicecenterAccess&amp;gt;.)|8(?&amp;lt;customerId&amp;gt;.{9})(?&amp;lt;fileSourceCode&amp;gt;.)(?&amp;lt;customerIdType&amp;gt;.)(?&amp;lt;mftCode&amp;gt;..)(?&amp;lt;planNumber&amp;gt;.{3})(?&amp;lt;period&amp;gt;.{6})(?&amp;lt;reasonCode&amp;gt;..)(?&amp;lt;caseStatusCode&amp;gt;.)(?&amp;lt;nameControl&amp;gt;.{4})(?&amp;lt;variabledata&amp;gt;.{12})(?&amp;lt;commandcodeDefiner&amp;gt;.)(?&amp;lt;hitIndicator&amp;gt;.)(?&amp;lt;errorCode&amp;gt;..)(?&amp;lt;recordDate&amp;gt;.{14})(?&amp;lt;terminalId&amp;gt;.{4})(?&amp;lt;employeeId&amp;gt;.{9})(?&amp;lt;servicecenterAccess&amp;gt;.))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Test Data:&lt;BR /&gt;
fR1298548476IMFOL45811782951S94613201805330BVFT            TY0120180730094327S017133330054j  Gf P&lt;BR /&gt;
cR0541654591SSNAD4FOE1323366S20766201804337VCKK            @00320180730094327S017133330036j  Hc D&lt;BR /&gt;
cR6514218124EINAD4DOE1302364S25590201805331AHKJ             N0520180730094327F041133330002j  Gc F&lt;BR /&gt;
cR7657215143SUMRY47779977772S03253201807334NCHE             Y0220180730094327R002379327465   Ec R&lt;BR /&gt;
cR5953482071INOLE41447259924E52121201801008DBTN            @N0420180730094327R002133330091   Hc R&lt;BR /&gt;
cR2898564174TXMOD46352542191E26920201802009KPDZ            S00520180730094327K013133330050j  Ic T&lt;BR /&gt;
cR2876775191TXMOD40323175371S61226201807335YBOV            @N0420180730094327S017133330043j  Jc C&lt;BR /&gt;
fT4708103013NAMES4FOE1323924S21496201803  4FXZD            @00320180730094327R002133330092   Af&lt;BR /&gt;&lt;BR /&gt;
fR0226672024NAMEE4DOE1302923S02315201801  0UNCY            SY0620180730094327F041133330002   Cf T&lt;BR /&gt;
fT4443253213SUMRY49999999992S30463201803333FOZX            T00120180730094327K013311133965   Df T&lt;BR /&gt;
fP1420916797BMFOL44990396344E25120201803336HKMW            @Y0120180730094327S017133330029   Ef T&lt;BR /&gt;
kR5817124797TXMOD41333317076E20196201804  8HDNN            T00220180730094327F041133330002j  Gk T&lt;BR /&gt;
kT1385586640NAMEI4LOE1323072S12910201807338IGCW             Y0520180730094327K013133330007j  Ak E&lt;BR /&gt;
kT7026180021TXMOD41333301812S54795201806  6NEJS            TY0620180730094327K013133330081   Ek P&lt;BR /&gt;
kT1368976488INOLE41928598383S95910201801331POUK            @00420180730094327K013133330006   Ik B&lt;BR /&gt;
kT6241906114BMFOL48639820266E09076201801005JFOU            SN0320180730094327K013133330071   Ck R&lt;BR /&gt;
mT1565694940TXMOD41333318816S01811201802009BFMB            SN0220180730094327S017133330002j  Fm A&lt;BR /&gt;
mP3400956518NAMEB4LOE1323073S71836201801  2CYPQ            @Y0520180730094327F041133330007   Cm I&lt;BR /&gt;
mT0860993636BMFOL41333317812S96115201802339TXAL            TN0220180730094327F041133330081j  Em C&lt;BR /&gt;
mP3570066946TXMOD48680158211E94493201802  9NVKA            TN0520180730094327F041133330050j  Gm C&lt;BR /&gt;
mT9350471607SUMRY43395544244S18645201807338XTXI            T00520180730094327K013133330067j  Dm 0&lt;BR /&gt;
mT7945532965IMFOL46939011953S17292201807  7XUJN            @Y0520180730094327K013133330038j  Hm E&lt;BR /&gt;
nP9107239233FINDS4MOE1323233E25241201801334JTMV            TY0420180730094327K013133330023   Hn T&lt;BR /&gt;
nR9886908780BMFOL45879043434S86927201806335TOUS            SN0220180730094327R002133330064   An&lt;BR /&gt;&lt;BR /&gt;
nT1655002017BMFOL40389284782E11452201803337RDFT            @00520180730094327K013133330059j  Fn&lt;BR /&gt;&lt;BR /&gt;
nT1809006537SUMRY45827717751E11772201806008VLIZ            @Y0620180730094327F041133330088j  Fn S&lt;BR /&gt;
nP8776887108IMFOL41136042474S31341201804005HSCY            T00220180730094327R002133330099j  An S&lt;BR /&gt;
oT7447732003INOLE45299216573S07923201802  2OSJH             Y0420180730094327K013303970591j  Co C&lt;BR /&gt;
oR1311120263SUMRY47957074552S17161201802  8IXZY            @N0320180730094327F041133330081j  Go T&lt;BR /&gt;
oT0055598373SUMRY49919638613E51825201807333SEWQ            TY0420180730094327R002133330096j  Ao P&lt;BR /&gt;
pP7215149590TXMOD41234567896E07625201804330UZDT            SN0520180730094327R002750896893   Ap D&lt;BR /&gt;
pR3044919804BMFOL41397076471S85267201803332DZEU            SN0120180730094327S017133330079   Ep I&lt;BR /&gt;
pP6477890655TXMOD42740203586E72127201801338DYCH            @Y0520180730094327R002133330091   Fp C&lt;BR /&gt;
tT7406671480FINDE4MOE1323233S58533201801  7JREW            @Y0320180730094327R002133330023   Ct 0&lt;BR /&gt;
tR8272783627TPIIP4MOE1323231E17923201807  4KFVL             00320180730094327S017133330023j  Et F&lt;BR /&gt;
tP1376447358TXMOD41234567894E03618201803  9YYSJ             Y0620180730094327K013321231331j  At P&lt;BR /&gt;
tT8384273729TXMOD48704147666S31521201806  5PDWU            TN0520180730094327S017133330015j  Bt A&lt;BR /&gt;
tR7020917196IMFOL47658161296S35359201806  4MTLM            @00120180730094327R002133330084j  It R&lt;BR /&gt;
tP3721208587IMFOL44685944314E07368201806  3EFMG            SN0320180730094327F041133330091   At F&lt;BR /&gt;
tP0946457554BMFOL42512904223S22413201806334ZEZG            TN0520180730094327S017133330062j  At D&lt;BR /&gt;
tT8358885950TXMOD48029926323E85699201805  7XVOJ            SY0320180730094327K013133330029j  Bt 0&lt;BR /&gt;
tR6725387706TXMOD49901804524S10029201803003SKDR            TN0420180730094327F041133330057j  Ct B&lt;BR /&gt;
uR0794067328INOLE48778236982S85621201807337YIMU            T00520180730094327F041133330027   Fu D&lt;BR /&gt;
uT7126960004TXMOD42856727322S25085201803331GPEX            @00420180730094327R002133330087   Bu&lt;BR /&gt;&lt;BR /&gt;
uP8872619046INOLE41010449672S25802201802339QVRG            TN0320180730094327S017133330064j  Cu P&lt;BR /&gt;
uT4988607071INOLE47912081553E64337201805  8HSQM            SN0220180730094327F041133330076j  Iu I&lt;BR /&gt;
fT0471962955INOLE64823464134E95309201806008ZKLX            S00120180730094327S017133330085j  Hf C&lt;BR /&gt;
fT3279240917INOLE61333300024E03804201801335BSFW            @00220180730094327R002133330002   Df&lt;BR /&gt;&lt;BR /&gt;
cP4324323016INOLE65119172171S02477201807  6GWBP            @N0420180730094327S017133330075   Ic 0&lt;BR /&gt;
cT4547213298IMFOL61333317021E25793201801  1JHHW            @00120180730094327K013133330002   Hc E&lt;BR /&gt;
fT1722386972IMFOL66274531273S30353201804  5GAJP            S00320180730094327R002133330019j  Df D&lt;BR /&gt;
fP8066089440SUMRY65767577066S31237201807  3DMVA             N0420180730094327K013133330068   If R&lt;BR /&gt;
fP0485546298TXMOD63561122034S60949201802336UYKK            S00120180730094327R002133330044   Ff&lt;BR /&gt;&lt;BR /&gt;
kT6365702862SUMRY65523659821S17636201804004QUTW            SY0520180730094327K013133330024j  Fk 0&lt;BR /&gt;
kP8580284912INOLE68025036804E38260201801339ZHCO             00520180730094327F041133330032   Jk T&lt;BR /&gt;
kR3750882848BMFOL61148962912E11015201802004YLCT             Y0120180730094327R002133330070   Bk A&lt;BR /&gt;
kT8698598113IMFOL63008486593S07600201802339UUNM            SY0420180730094327R002133330050j  Hk E&lt;BR /&gt;
mP6970348535TXMOD61365287331E72748201804334TKQU            SN0320180730094327K013133330028j  Dm I&lt;BR /&gt;
mP4346669023TXMOD62447281613E97165201805335NROE            TY0320180730094327S017133330024j  Fm A&lt;BR /&gt;
mR2254832389SUMRY65219572171S12941201803333FMMD            TY0620180730094327F041133330017   Dm F&lt;BR /&gt;
nP0791300073INOLE65299216573S32593201807005JGHT             N0220180730094327R002790580021j  Jn S&lt;BR /&gt;
nP5237696211TXMOD66966905522E38294201802008GRNU            S00120180730094327K013133330087j  An R&lt;BR /&gt;
nT3017798844IMFOL65860965632S52761201803000GAAF             Y0420180730094327R002133330043j  Jn A&lt;BR /&gt;
nR3326954123TXMOD61549583014S26867201805005MURC            SN0420180730094327S017133330093j  In T&lt;BR /&gt;
nT0861273555BMFOL61998010194E20651201802332VHDM            TN0120180730094327R002133330059j  Jn T&lt;BR /&gt;
oP9036501288BMFOL61333318743S18404201805  3TXNE            @N0620180730094327S017133330002j  Fo E&lt;BR /&gt;
oT1759941218TXMOD61333300021E71832201805002VIBE            @N0320180730094327S017133330002   Eo I&lt;BR /&gt;
oT6582800203BMFOL62446659214S32976201804  4FFXY            @N0120180730094327R002133330017   Ao F&lt;BR /&gt;
oR7939342733SUMRY69379014136E60957201803335RUWJ            S00120180730094327R002133330098   Fo S&lt;BR /&gt;
oP8862288714SUMRY68206040392E60825201803331HNBX            T00220180730094327K013133330064   Go A&lt;BR /&gt;
pP2769085422IMFOL61333300021E20141201804004RCWD            TN0120180730094327K013133330002j  Hp T&lt;BR /&gt;
pP7409691286SUMRY62104877296E95805201805004FHJQ            @00120180730094327K013133330038j  Ep T&lt;BR /&gt;
pT9068663789BMFOL69302987094E51001201806008ZGAZ            TN0120180730094327K013133330077   Jp S&lt;BR /&gt;
pR5149288095IMFOL60520590396S19802201804339ZWDX            TY0420180730094327S017133330056   Cp&lt;BR /&gt;&lt;BR /&gt;
pP0633308829TXMOD69994222534E78363201807333WERI            TN0520180730094327K013133330019j  Ep S&lt;BR /&gt;
pT7700784907INOLE66078403092E53076201801002QWEF            @N0520180730094327K013133330056j  Gp D&lt;BR /&gt;
tT6886055451BMFOL61572105781E58414201803  9WJEB            T00220180730094327K013133330063j  Dt F&lt;BR /&gt;
tR5241526864TXMOD62151614984E05704201802330QHOK            TY0620180730094327K013133330013j  At C&lt;BR /&gt;
tP4417067141INOLE65375500761S06504201801  0WTQM            @00120180730094327K013133330097   It F&lt;BR /&gt;
tP5586690268TXMOD63100844686S11257201804335VUTI             N0320180730094327S017133330012j  Dt C&lt;BR /&gt;
uT0554281764IMFOL68306186783E60385201805  4DAIB            @00620180730094327K013133330099   Bu R&lt;BR /&gt;
uR4461381008TXMOD63241903884E94776201804  2ZOFQ             N0120180730094327F041133330053   Du S&lt;BR /&gt;
uR4398039459BMFOL67319955666E53320201807004IAJE            TN0520180730094327K013133330083   Hu S&lt;BR /&gt;
cR8352776094BMFOL82862187046S06054201804338RCUW            @00120180730094327S017133330048   Gc A&lt;BR /&gt;
cR4800640192INOLE89652584754S93138201803001OMRS            T00120180730094327R002133330008   Hc I&lt;BR /&gt;
cR8985007583BMFOL82492120606E20531201805337MLGI            @N0520180730094327F041133330016   Ac S&lt;BR /&gt;
cP9888831767IMFOL83656331773S86861201803004YKHC            T00320180730094327R002133330096j  Hc T&lt;BR /&gt;
cP8618959181SUMRY81944198781S45279201804000CADU             00220180730094327R002133330068   Gc 0&lt;BR /&gt;
cT4521083787TXMOD82278039513S02272201804334NVDY            @N0220180730094327F041133330034j  Dc I&lt;BR /&gt;
fP2564275283IMFOL80318031326E30882201801  5GHZR            SY0420180730094327S017133330042j  Gf A&lt;BR /&gt;
fP4528534747IMFOL86708734682E60857201807  4QYXH            T00220180730094327F041133330087j  Df B&lt;BR /&gt;
fR7161291737TXMOD88086378453E08129201806001HMET            S00420180730094327K013133330055j  Cf R&lt;BR /&gt;
fR3735322969SUMRY87928205732E10427201807337LGME            @00420180730094327K013133330022   Df I&lt;BR /&gt;
kT4357356706INOLE89999999996E95908201802  6ZHSG            @00420180730094327S017460292587   Fk S&lt;BR /&gt;
kP0566601474BMFOL85154258532S21164201805333FKZH            SN0620180730094327K013133330019   Gk P&lt;BR /&gt;
kP6203899824TXMOD86113408923E64157201804  1WLXF             00220180730094327F041133330024j  Dk D&lt;BR /&gt;
kR1503975361BMFOL82128079591E52786201801  4QEQA            TN0620180730094327S017133330048j  Bk I&lt;BR /&gt;
kR0588299223TXMOD84388149554E35796201801337WCSU            @00120180730094327R002133330029j  Ek F&lt;BR /&gt;
mT9849663219IMFOL89999999994E93642201807  0PACC             Y0620180730094327R002339340904j  Im&lt;BR /&gt;&lt;BR /&gt;
mT2828410726BMFOL84853240732E05935201803004AWRM            T00620180730094327K013133330060   Am A&lt;BR /&gt;
mT9032854047TXMOD89419660584S45810201802006ZANV             00520180730094327F041133330018j  Gm A&lt;BR /&gt;
mP0697635410TXMOD82647299231S45874201807336OLNW            @N0620180730094327K013133330031   Im P&lt;BR /&gt;
mT5071611163IMFOL80689627656E64065201802  5UCNK             00220180730094327K013133330012j  Im R&lt;BR /&gt;
nT7246638337TXMOD81333317741S32395201806  0WKWN            @N0520180730094327K013133330002   Fn S&lt;BR /&gt;
nR5495138073SUMRY83794664972S07307201805  1VCWZ            TY0320180730094327K013133330010j  Dn S&lt;BR /&gt;
nR2384675412BMFOL86169853296S25077201805333WBHW            TN0320180730094327F041133330035j  Gn I&lt;BR /&gt;
oP0656761680IMFOL86340423763E11149201807001SBWM            TY0220180730094327K013133330006j  Bo T&lt;BR /&gt;
oP0985178823TXMOD86064555104E64700201805001TIIK             Y0420180730094327S017133330075j  Go E&lt;BR /&gt;
oR4013244087IMFOL83698777514E49302201803000DREY            TY0320180730094327R002133330087j  Ao E&lt;BR /&gt;
oT9138665736IMFOL89163731651E02858201802007LGOA            @00620180730094327F041133330049j  Ho S&lt;BR /&gt;
oR6611294272TXMOD87738266126S85914201805008KJFU            S00520180730094327F041133330018   Bo E&lt;BR /&gt;
pP1123052654BMFOL81333300743S51637201807  6RDUL            SY0520180730094327S017133330002   Gp P&lt;BR /&gt;
pR8042075137SUMRY80781949931E54658201805004VLLD             N0220180730094327R002133330091j  Cp E&lt;BR /&gt;
pP0084188498IMFOL83666867631S30525201807  9AYAX            @00220180730094327S017133330018   Cp T&lt;BR /&gt;
pT6041235188IMFOL85464344773E06931201805004XWIN             00520180730094327R002133330002   Cp C&lt;BR /&gt;
uT1539545402INOLE81333300023S23326201801  9WPLG            TY0520180730094327S017133330002j  Bu A&lt;BR /&gt;
uR4927222962BMFOL85299216576E17285201802007CROQ            TN0420180730094327K013944833579   Fu S&lt;BR /&gt;
uR4609034898SUMRY80479401391S54577201805334YXKJ            TN0120180730094327K013133330064j  Cu C&lt;BR /&gt;
uR2432538664BMFOL82972196553S09631201801  8CKNP            @00220180730094327R002133330028j  Gu E&lt;BR /&gt;
uP7398842392TXMOD88709474323S85557201806338BTSH             N0220180730094327K013133330099j  Au E&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 13:45:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396438#M115117</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-07-14T13:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396439#M115118</link>
      <description>&lt;P&gt;It would be helpful if you would paste some sample events of each type so we can test regular expressions.  Please don't screenshot the data.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 15:59:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396439#M115118</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-07-14T15:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396440#M115119</link>
      <description>&lt;P&gt;Sure @ richgalloway. See below. Do notice that sometimes, one of the field/s may not have data but field position is fixed so that can be filled with "unknown" value or left blank. Please copy/paste below in notepad for looking. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Format Code 4 Sample breakdown:&lt;/STRONG&gt;&lt;BR /&gt;
b|R|7225256004|BMFOL|4|7779977771S58628201804333EFUJ            |S|0|04|20180730094327|R002|698517851|j|  Jb P&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Format Code 4 Samples:&lt;/STRONG&gt;&lt;BR /&gt;
bR7225256004BMFOL47779977771S58628201804333EFUJ            S00420180730094327R002698517851j  Jb P&lt;BR /&gt;
fR7161291737TXMOD88086378453E08129201806005PQRS            S00420180730094327K013133330055j  Cf R&lt;BR /&gt;
fR1298548476IMFOL45811782951S94613201805336UVWX            TY0120180730094327S017133330054j  Gf P&lt;BR /&gt;
fT0471962955INOLE64823464134E95309201806001ABCD            S00120180730094327S017133330085j  Hf C&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Format Code 6 Sample breakdown:&lt;/STRONG&gt;&lt;BR /&gt;
b|P|3729146654|TXMOD|6133330102|6|E|20361201803007VZHU           |  |N|03|20180730094327|K013|133330002|   Bb 0&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Format Code 6 Samples:&lt;/STRONG&gt;&lt;BR /&gt;
bP3729146654TXMOD61333301026E20361201803007VZHU             N0320180730094327K013133330002   Bb 0&lt;BR /&gt;
fR3735322969SUMRY87928205732E10427201807339EFGH            @00420180730094327K013133330023   Df I&lt;BR /&gt;
fP1420916797BMFOL44990396344E25120201803330IJKL            @Y0120180730094327S017133330029   Ef T&lt;BR /&gt;
fP1420916797BMFOL44990396344E25120201803333BDES            @Y0120180730094327S017133330029   Ef T&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Format Code 8 Sample breakdown:&lt;/STRONG&gt;&lt;BR /&gt;
b|T|9593420235|IMFOL|8|133330002|2|S|45|253|201802|  4|N|XKN            |T|Y|04|20180730094327|K013|133330002| |  Cb P&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Format Code 8 Samples:&lt;/STRONG&gt;&lt;BR /&gt;
bT9593420235IMFOL81333300022S45253201802  0ZXYN            TY0420180730094327K013133330002   Cb P&lt;BR /&gt;
fP0485546298TXMOD63561122034S60949201802338ABCD            S00120180730094327R002133330044   Ff&lt;BR /&gt;
fT4708103013BMFOL41333318024S21496201803  ABCDE            @00320180730094327R002133330002   Af D&lt;BR /&gt;
fT3279240917INOLE61333300024E0380420180133FGHIJ            @00220180730094327R002133330002   Df&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 17:02:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396440#M115119</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-07-14T17:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396441#M115120</link>
      <description>&lt;P&gt;This regex matches your sample events, but format 8 appears to missing the last 2 fields (Employee No and Center Access).  Perhaps I missed something, but I think this gives you an idea of how to proceed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?J)^(?&amp;lt;branchCode&amp;gt;.)(?&amp;lt;mode&amp;gt;.)(?&amp;lt;employeeId&amp;gt;.{10})(?&amp;lt;eventCode&amp;gt;.{5})(?&amp;lt;format&amp;gt;4(?&amp;lt;data&amp;gt;.{30})(?&amp;lt;codeDefiner&amp;gt;.)(?&amp;lt;hzIndicator&amp;gt;.)(?&amp;lt;errorCode&amp;gt;..)(?&amp;lt;recordDate&amp;gt;.{14})(?&amp;lt;terminalId&amp;gt;.{4})(?&amp;lt;employeeNo&amp;gt;.{9})(?&amp;lt;centerAccess&amp;gt;.)|6(?&amp;lt;customerId&amp;gt;.{9})(?&amp;lt;fileSourceCode&amp;gt;.)(?&amp;lt;idType&amp;gt;.)(?&amp;lt;data&amp;gt;.{19})(?&amp;lt;codeDefiner&amp;gt;.)(?&amp;lt;hzIndicator&amp;gt;.)(?&amp;lt;errorCode&amp;gt;..)(?&amp;lt;recordDate&amp;gt;.{14})(?&amp;lt;terminalId&amp;gt;.{4})(?&amp;lt;employeeNo&amp;gt;.{9})(?&amp;lt;centerAccess&amp;gt;.)|8(?&amp;lt;customerId&amp;gt;.{9})(?&amp;lt;fileSourceCode&amp;gt;.)(?&amp;lt;idType&amp;gt;.)(?&amp;lt;mftCode&amp;gt;..)(?&amp;lt;planNumber&amp;gt;.{3})(?&amp;lt;period&amp;gt;.{6})(?&amp;lt;reasonCode&amp;gt;..)(?&amp;lt;caseStatusCode&amp;gt;.)(?&amp;lt;nameControl&amp;gt;.{4})(?&amp;lt;data&amp;gt;.{12})(?&amp;lt;codeDefiner&amp;gt;.)(?&amp;lt;hzIndicator&amp;gt;.)(?&amp;lt;errorCode&amp;gt;..)(?&amp;lt;recordDate&amp;gt;.{14})(?&amp;lt;terminalId&amp;gt;.{4}))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To extract the format code alone, use &lt;CODE&gt;| rex field=format "(?&amp;lt;format&amp;gt;.)"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 20:48:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396441#M115120</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-07-14T20:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396442#M115121</link>
      <description>&lt;P&gt;I HATE SCREENSHOTTED DATA!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 03:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396442#M115121</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-15T03:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396443#M115122</link>
      <description>&lt;P&gt;OK, so you told us where the field breaks are, but not the field names.  And you use &lt;CODE&gt;(?P&amp;lt;name&amp;gt;)&lt;/CODE&gt; variation so it ate you field names (do not use the &lt;CODE&gt;P&lt;/CODE&gt;).&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 03:12:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396443#M115122</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-15T03:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396444#M115123</link>
      <description>&lt;P&gt;Only your &lt;CODE&gt;Format4&lt;/CODE&gt; data matches your chart, but in any case, here is how you would do it (with slight adjustments to match what you really have):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="bR7225256004BMFOL47779977771S58628201804333EFUJ S00420180730094327R002698517851j Jb P:::fR7161291737TXMOD88086378453E08129201806005PQRS S00420180730094327K013133330055j Cf R:::fR1298548476IMFOL45811782951S94613201805336UVWX TY0120180730094327S017133330054j Gf P:::fT0471962955INOLE64823464134E95309201806001ABCD S00120180730094327S017133330085j Hf C:::bP3729146654TXMOD61333301026E20361201803007VZHU N0320180730094327K013133330002 Bb 0:::fR3735322969SUMRY87928205732E10427201807339EFGH @00420180730094327K013133330023 Df I:::fP1420916797BMFOL44990396344E25120201803330IJKL @Y0120180730094327S017133330029 Ef T:::fP1420916797BMFOL44990396344E25120201803333BDES @Y0120180730094327S017133330029 Ef T:::bT9593420235IMFOL81333300022S45253201802 0ZXYN TY0420180730094327K013133330002 Cb P:::fP0485546298TXMOD63561122034S60949201802338ABCD S00120180730094327R002133330044 Ff:::fT4708103013BMFOL41333318024S21496201803 ABCDE @00320180730094327R002133330002 Af D:::fT3279240917INOLE61333300024E0380420180133FGHIJ @00220180730094327R002133330002 Df" 
| makemv delim=":::" raw 
| mvexpand raw 
| rename raw AS _raw 

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| rex "^(?&amp;lt;Branch_Code&amp;gt;.{1})(?&amp;lt;Mode&amp;gt;.{1})(?&amp;lt;Employee_ID&amp;gt;.{10})(?&amp;lt;Event_Code&amp;gt;.{5})(?&amp;lt;Format_Code&amp;gt;.{1})(?&amp;lt;Variable_Data&amp;gt;.{30})(?&amp;lt;Code_Definer&amp;gt;.{1})(?&amp;lt;Hit_Indicator&amp;gt;.{1})(?&amp;lt;Error_Code&amp;gt;.{2})(?&amp;lt;Record_Date&amp;gt;.{14})(?&amp;lt;Terminal_ID&amp;gt;.{4})(?&amp;lt;Employee_No&amp;gt;.{9})(?&amp;lt;Center_Access&amp;gt;.{1})(?&amp;lt;F4_EXTRA&amp;gt;.{5})"
| rex "^(?&amp;lt;Branch_Code&amp;gt;.{1})(?&amp;lt;Mode&amp;gt;.{1})(?&amp;lt;Employee_ID&amp;gt;.{10})(?&amp;lt;Event_Code&amp;gt;.{5})(?&amp;lt;Format_Code&amp;gt;.{1})(?&amp;lt;Customer_ID&amp;gt;.{10})(?&amp;lt;File_Source_Code&amp;gt;.{1})(?&amp;lt;ID_Type&amp;gt;.{1})(?&amp;lt;Variable_Data&amp;gt;.{30})(?&amp;lt;Code_Definer&amp;gt;.{1})(?&amp;lt;Hit_Indicator&amp;gt;.{1})(?&amp;lt;Error_Code&amp;gt;.{2})(?&amp;lt;Record_Date&amp;gt;.{14})(?&amp;lt;Terminal_ID&amp;gt;.{4})(?&amp;lt;Employee_No&amp;gt;.{9})(?&amp;lt;Center_Access&amp;gt;.{1})(?&amp;lt;F6_EXTRA&amp;gt;.{5})"
| rex "^(?&amp;lt;Branch_Code&amp;gt;.{1})(?&amp;lt;Mode&amp;gt;.{1})(?&amp;lt;Employee_ID&amp;gt;.{10})(?&amp;lt;Event_Code&amp;gt;.{5})(?&amp;lt;Format_Code&amp;gt;.{1})(?&amp;lt;Customer_ID&amp;gt;.{9})(?&amp;lt;File_Source_Code&amp;gt;.{1})(?&amp;lt;ID_Type&amp;gt;.{1})(?&amp;lt;MFT_code&amp;gt;.{2})(?&amp;lt;Port_Number&amp;gt;.{3})(?&amp;lt;Period&amp;gt;.{6})(?&amp;lt;Reason_Code&amp;gt;.{2})(?&amp;lt;Case_Status_Code&amp;gt;.{1})(?&amp;lt;Name_control&amp;gt;.{4})(?&amp;lt;Variable_Data&amp;gt;.{12})(?&amp;lt;Code_Definer&amp;gt;.{1})(?&amp;lt;Hit_Indicator&amp;gt;.{1})(?&amp;lt;Error_Code&amp;gt;.{2})(?&amp;lt;Record_Date&amp;gt;.{14})(?&amp;lt;Terminal_ID&amp;gt;.{4})(?&amp;lt;Employee_No&amp;gt;.{9})(?&amp;lt;Center_Access&amp;gt;.{1})(?&amp;lt;F8_EXTRA&amp;gt;.{5})"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jul 2019 14:10:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396444#M115123</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-15T14:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396445#M115124</link>
      <description>&lt;P&gt;Thanks A LOT @richgalloway for promptness. Please see Addendum in question and initial response of @woodcock. Need some additional guidance pls. TY!!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 16:11:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396445#M115124</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-07-17T16:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396446#M115125</link>
      <description>&lt;P&gt;Thanks A LOT @woodcock for promptness. Please see Addendum in question. Need some additional guidance pls. TY!!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 16:20:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396446#M115125</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-07-17T16:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396447#M115126</link>
      <description>&lt;P&gt;So you accepted an answer which is fine.  If you have additional needs, please post a new answer.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2019 14:16:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396447#M115126</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-28T14:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396448#M115127</link>
      <description>&lt;P&gt;Thanks @woodcock, all good at the moment. Used both but can accept only one. I have up-voted yours as well &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 03:43:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396448#M115127</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-07-29T03:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Fields extraction from TXT file with fixed position varrying event formats in each line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396449#M115128</link>
      <description>&lt;P&gt;I don't see the &lt;CODE&gt;UpVote&lt;/CODE&gt; but that's the way you do it, for sure.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 05:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fields-extraction-from-TXT-file-with-fixed-position-varrying/m-p/396449#M115128</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-29T05:44:45Z</dc:date>
    </item>
  </channel>
</rss>

